The document describes a C++ program that uses object-oriented programming concepts to represent matrices and perform operations on them such as reading, writing, adding, summing elements, and finding the maximum element. The main functionality includes defining a struct to represent matrix elements and nodes, reading in matrices from user input, writing matrices to output, adding two matrices by iterating through their elements, summing all elements of a matrix, and finding the maximum value and its position. The program uses a menu to allow the user to choose which operation to perform on sample matrices.
C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
This reference will take you through simple and practical approach while learning C++ Programming language.
C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
This reference will take you through simple and practical approach while learning C++ Programming language.
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
program to convert decimal number into roman number
program of prime number
program to print total number of times a given number exist from 1 to 100
program to compare two given matrices
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Standing the Test of Time: The Date Provider PatternDerek Lee Boire
Presented at the April 1, 2017 Tokyo iOS Meetup, in this presentation I talk about how you can test logic that depends on the current date and time by utilizing the "Date Provider" pattern. By simply passing in a Date Provider to the method that needs access to the current date & time, you can easily create a fake/mock object that can be used to test this logic.
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
program to convert decimal number into roman number
program of prime number
program to print total number of times a given number exist from 1 to 100
program to compare two given matrices
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Standing the Test of Time: The Date Provider PatternDerek Lee Boire
Presented at the April 1, 2017 Tokyo iOS Meetup, in this presentation I talk about how you can test logic that depends on the current date and time by utilizing the "Date Provider" pattern. By simply passing in a Date Provider to the method that needs access to the current date & time, you can easily create a fake/mock object that can be used to test this logic.
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docxAdamq0DJonese
/* Task 2: Debugging a program with stacks, queues, and doubly-linked lists There are a number of errors in the following program. All errors are located in main() and structure definitions. Function declarations and definitions are correct! Locate all errors, fix them (as shown below), run the program and save its output as a comment at the end of the source file. Example: int num = 10; int *ptr; num = &ptr; // <== Error: Comment the line and write the correct line below // Write a short justification where appropriate // num = &ptr; // Error #1 ptr = # Name: */ #include #include #include #include #define DUMMY_TRAILER '\177' // octal ASCII code of the // last character in the ASCII table #define NUM_CITIES 10 typedef struct { char name[12]; int temperature[5]; } CITY; // Stack and Queue Node typedef struct node NODE; struct node { CITY city; node *next; }; // Doubly Linked List Node typedef struct d_node D_NODE; struct d_node { CITY city; NODE *forw; NODE *back; }; // Stack Functions NODE *push(NODE *stack, const CITY *pStu); NODE *pop(NODE **stack); // Queue Functions void enqueue(NODE **queue, NODE **rear, const CITY *pStu); NODE *dequeue(NODE **queue, NODE **rear); // Doubly Linked List Functions D_NODE *init_list(void); int insert(D_NODE *list, const CITY *pStu); void traverse_forw(D_NODE *list); void traverse_back(D_NODE *list); // Other Functions void printCity(const CITY *pCity); int main (void) { CITY cList[NUM_CITIES] = { {"Cupertino", {88, 89, 87, 85, 89}}, {"Flagstaff", {81, 80, 88, 89, 89}}, {"Los Angeles", {87, 88, 89, 89, 90}}, {"Philadelphia", {96, 99, 99, 90, 95}}, {"Phoenix", {106, 109, 109, 100, 105}}, {"Portland", {89, 90, 85, 89, 90}}, {"Reno", {108, 105, 109, 100, 108}}, {"Salem", {85, 90, 85, 89, 90}}, {"Tucson", {107, 100, 109, 100, 108}}, {"Yreka", {101, 109, 100, 108, 109}} }; NODE *stack = NULL; NODE *top = NULL; NODE *queue = NULL, *rear = NULL; NODE *front; D_NODE *list; list = init_list(); // build stack and queue with data from an array of CITY structures srand((unsigned int)time(NULL)); int count = rand() % 10; for ( int n = 0; n < count; n++) { int i = rand() % NUM_CITIES; int duplicate = insert(list, &cList[i]); if(duplicate) { // already in the list! push(stack, &cList[i]); enqueue(&queue, &rear, cList[i]); } } // display list printf("\nLIST contents (forwards):\n"); traverse_forw(list); printf("\nLIST contents (backwards):\n"); traverse_back(list); // display stack if (top) { printf("\nSTACK contents from top to bottom:\n"); while ((top = pop(stack))) { printCity(top->city); } } else printf ("Empty Stack!\n"); // display queue if (front) { printf("\nQUEUE contents from front to rear:\n"); while ((front = dequeue( queue, rear))) { printCity(front->city); } } else printf ("Empty Queue!\n"); return 0; } /*************************************************** Displays the fileds of a CIS_CLASS structure Pre pCls - a pointer to a CIS_CLASS structure Post */ void printCity(const CITY *pCity) { printf("%-20s %3d\n",.
Data StructuresPLEASE USING THIS C++ PROGRAM BELOW, I NEED HEL.pdfrozakashif85
Data Structures
PLEASE USING THIS C++ PROGRAM BELOW, I NEED HELP ON IMPLEMENTING
BOTH QUEUE AND STACK TO PRINT \"I able\"
REVERSE/BACKWARDS(PALINDROME)
#include
#include
using namespace std;
struct st
{
int year;
st *next;
};
class queue
{
public:
int sz,i = 0;
char chr[100];
queue()
{
//constructor for initializing front and rear to NULL
front = NULL;
rear = NULL;
cout << \"enter size of queue: \";
cin >> sz;
}
// ~queue()
// {
//
// }
// in the enterqueue, create a new node, assign value and add it to queue
// if F = R = NULL the ( ) else ( )
void enterqueue(int yr, char el)
{
//inserting into queue if queue not overflow
if(i >= sz)
{
cout << \"queue over flow\";
return;
}
if (front == NULL )
{
front = new st;
front->next = NULL;
front->year = yr;
rear = front;
chr[i] = el;
i++;
}
else
{
st *temp = new st;
temp->year = yr;
rear->next = temp;
rear = temp;
chr[i] = el;
i++;
}
}
char deletequeue()
{
//delete front data from queue if data in the queue
char tr;
int j = 0;
st *temp;
temp = front;
if( front == NULL)
{
cout << \"queue under flow\";
return \'a\';
}
if(front == rear)
{
front = rear = NULL;
return \'a\';
}
front = front->next;
delete temp;
tr = chr[0];
i--;
for(j = 0; j < i; j++)
{
chr[j] = chr[j+1];
}
chr[j] = \'\\0\';
return tr;
}
bool isempty()
{
//it shows whether queue is empty
if( front == NULL)
{
return true;
}
else
return false;
}
bool isfull()
{
//it shows whether queue is full
if(i == sz)
return true;
else
return false;
}
void display()
{
//it displays queue data with characters of queue if invalid choice is entered
st *tmp;
int j = 0;
cout << \"\ queue is:\ character \\tyear\";
for(tmp = front; tmp != rear; tmp = tmp->next, j++)
{
cout << \"\ \" << chr[j] << \" \" << tmp->year;
}
cout << \"\ \"<year;
}
private:
st *front, *rear;
};
int main()
{
//main method to call queue functions by choice
queue s1;
int ch,yr;
char el;
bool s;
while(1)
{
cout << \"\ 1.ENTERQUEUE\ 2.DELETEQUEUE\ 3.ISEMPTY\ 4.ISFULL\ 5.EXIT\ enter
your choice: \";
cin >> ch;
switch(ch)
{
case 1:
if(!s1.isfull())
{
cout << \"\ enter a year : \";
cin >> yr;
cout << \"\ enter a character : \";
cin >> el;
s1.enterqueue(yr, el);
}
else
cout << \"insertion not possible\";
break;
case 2:
s = s1.isempty();
if(!s)
{
el = s1.deletequeue();
cout << \"\ The character of queue \" << el <<\" is deleted\" << endl;
}
else
cout << \"\ queue is empty.deletion not possible\"<< endl;
break;
case 3:
s = s1.isempty();
if(s)
cout << \"\ queue is empty\" << endl;
else
cout << \"\ queue is not empty\" << endl;
break;
case 4:
s=s1.isfull();
if(s)
cout << \"\ queue is full\" << endl;
else
cout << \"\ queue is not full\" << endl;
break;
case 5:
exit(0);
default : cout << \"invalid choice\" << endl;
if(!s1.isempty())
s1.display();
}
}
return (0);
}
Solution
#include
#include
using namespace std;
struct st
{
int year;
st *next;
};
class queue
{
public:
//int sz,i=0;//modified //code modified here// everything is fine with the code except this...
queue is implemented correctly
//you can .
I need to fill-in TODOs in .cpp file and in .h file Could some.pdfforladies
I need to fill-in //TODO\'s in .cpp file and in .h file
Could someone help me at least with few of them to give me an idea how deal with it.
***SinglyLinkedList.cpp
#include
#include
#include \"SinglyLinkedList.h\"
void test_constructor() {
SinglyLinkedList lst = {100, 200, 300, 400, 500};
assert(*lst.at(0) == 100);
assert(*lst.at(1) == 200);
assert(*lst.at(2) == 300);
assert(*lst.at(3) == 400);
assert(*lst.at(4) == 500);
assert(lst.size() == 5);
}
void test_remove() {
SinglyLinkedList lst = {100, 200, 300, 400, 500};
lst.remove(2);
assert(*lst.at(0) == 100);
assert(*lst.at(1) == 200);
assert(*lst.at(2) == 400);
assert(*lst.at(3) == 500);
assert(lst.size() == 4);
}
void test_insert() {
// TODO
}
void test_push_back() {
// TODO
}
void test_push_front() {
// TODO
}
void test_append() {
// TODO
}
void test_sum() {
// TODO
}
int main() {
test_constructor();
test_remove();
test_insert();
test_push_back();
test_push_front();
test_append();
test_sum();
}
***SinglyLinkedList.h
#include
#include
template
class SinglyLinkedList {
// Nested class representing the nodes in the list.
class SinglyLinkedListNode {
public:
// The value stored in this node.
T value;
// The next node in the sequence.
SinglyLinkedListNode *next;
SinglyLinkedListNode(T value) :
value(value), next(nullptr) {}
SinglyLinkedListNode(T value, SinglyLinkedListNode *next) :
value(value), next(next) {}
// Return the size (length) of the linked list.
std::size_t size();
};
SinglyLinkedListNode *head;
SinglyLinkedListNode *tail;
public:
// Constructs a new SinglyLinkedList from an initializer_list of type T[].
// This is mostly for convenience, especially when testing.
SinglyLinkedList(std::initializer_list items) : head(nullptr), tail(nullptr) {
if (items.size() == 0) {
return;
}
// initializer_lists were designed to be used iteratively,
// so thats what we do.
// Can you think of how to write this recursively?
auto it = items.begin();
while (it != items.end()) {
this->push_back(*it++);
}
}
// Return a pointer to the value at the given index.
// If the index is larger than the size of the list,
// return a nullptr.
//
// ASIDE: We will cover exceptions later.
T* at(std::size_t i);
// Pushes a new node onto the back of the list.
void push_back(T value);
// Pushes a new node onto the front of the list.
void push_front(T value);
// Return the size (length) of the linked list.
std::size_t size();
// Remove the specified node from the list.
void remove(std::size_t i);
// Insert the value at the index.
void insert(std::size_t i, T value);
// Append the given list to this one.
void append(SinglyLinkedList list);
};
template
T* SinglyLinkedList::at(std::size_t i) {
// TODO
}
template
void SinglyLinkedList::push_back(T value) {
// TODO
// Make sure that this is a O(1) operation!
}
template
void SinglyLinkedList::push_front(T value) {
// TODO
// Make sure that this is a O(1) operation!
}
template
void SinglyLinkedList::remove(std::size_t i) {
// TODO
// Don\'t forget to not only unlink the node, b.
–PLS write program in c++Recursive Linked List OperationsWrite a.pdfpasqualealvarez467
–PLS write program in c++
Recursive Linked List Operations
Write a C++ to manage a list of string elements. Besides the basic operations expected of a
linked list (add an element, remove an element, check for empty list, report size (number) of
elements in the list, and print out the content of the list), the linked list class also needs to have a
method called sort() and a method called reverse() the manipulate the string elements. The sort
method rearranges the elements in the list so they are sorted in alphabetical order. The reverse
method reverses the order of the elements of the list. The class should use recursion to
implement the sort and reverse operations
Solution
#include
#include
#include
#include
struct node //declaring node
{
int info;
struct node *next;
}*start;
class single_llist //declaring class
{
public:
node* create_node(int);
void insert_begin();
void insert_pos();
void insert_last();
void delete_pos();
void sort();
void reverse();
void display();
single_llist()
{
start = NULL;
}
};
main()
{
int choice, nodes, position, i;
char str[100];
single_llist sl;
start = NULL;
while (1)
{
cout<>choice;
switch(choice)
{
case 1:
cout<<\"Inserting Node at Beginning: \"<info = value;
temp->next = NULL;
return temp;
}
}
/*
* Inserting element in beginning
*/
void single_llist::insert_begin()
{
int value;
cout<<\"Enter the value to be inserted: \";
cin>>value;
struct node *temp, *p;
temp = create_node(value);
if (start == NULL)
{
start = temp;
start->next = NULL;
}
else
{
p = start;
start = temp;
start->next = p;
}
cout<<\"Element Inserted at beginning\"<>value;
struct node *temp, *s;
temp = create_node(value);
s = start;
while (s->next != NULL)
{
s = s->next;
}
temp->next = NULL;
s->next = temp;
cout<<\"Element Inserted at last\"<>value;
struct node *temp, *s, *ptr;
temp = create_node(value);
cout<<\"Enter the postion at which node to be inserted: \";
cin>>pos;
int i;
s = start;
while (s != NULL)
{
s = s->next;
counter++;
}
if (pos == 1)
{
if (start == NULL)
{
start = temp;
start->next = NULL;
}
else
{
ptr = start;
start = temp;
start->next = ptr;
}
}
else if (pos > 1 && pos <= counter)
{
s = start;
for (i = 1; i < pos; i++)
{
ptr = s;
s = s->next;
}
ptr->next = temp;
temp->next = s;
}
else
{
cout<<\"Positon out of range\"<next;s !=NULL;s = s->next)
{
if (strcmp(ptr->info > s->info))
{
value = ptr->info;
ptr->info = s->info;
s->info = value;
}
}
ptr = ptr->next;
}
}
void single_llist::delete_pos() //delete element from given position
{
int pos, i, counter = 0;
if (start == NULL)
{
cout<<\"List is empty\"<>pos;
struct node *s, *ptr;
s = start;
if (pos == 1)
{
start = s->next;
}
else
{
while (s != NULL)
{
s = s->next;
counter++;
}
if (pos > 0 && pos <= counter)
{
s = start;
for (i = 1;i < pos;i++)
{
ptr = s;
s = s->next;
}
ptr->next = s->next;
}
else
{
cout<<\"Position out of range\"<next == NULL)
{
return;
}
ptr1 = start;
ptr2 = ptr1->next;
ptr3 = ptr2->next;
ptr1->next = NULL;
ptr2->next = ptr1;
while (ptr3 != NULL)
{
ptr1 = ptr2;
ptr2.
I am Daniel N. I am a C++ Homework Expert at cpphomeworkhelp.com. I hold a Masters in Programming from the University of Leeds, UK. I have been helping students with their homework for the past 10 years. I solve homework related to C++.
Visit cpphomeworkhelp.com or email info@cpphomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with C++ Homework.
Program of sorting using shell sort #include stdio.h #de.pdfanujmkt
/* Program of sorting using shell sort */
#include
#define MAX 20
main()
{
int arr[MAX], i,j,k,n,incr;
printf(\"Enter the number of elements : \");
scanf(\"%d\",&n);
for(i=0;i=1)
{
for(j=incr;j= 0 && k < arr[i]; i = i-incr)
arr[i+incr]=arr[i];
arr[i+incr]=k;
}
printf(\"Increment=%d \ \",incr);
for (i = 0; i < n; i++)
printf(\"%d \", arr[i]);
printf(\"\ \");
incr=incr-2; /*Decrease the increment*/
}/*End of while*/
printf(\"Sorted list is :\ \");
for (i = 0; i < n; i++)
printf(\"%d \", arr[i]);
printf(\"\ \");
}/*End of main()*/
redix sort
/*Program of sorting using radix sort*/
# include
# include
struct node
{
int info ;
struct node *link;
}*start=NULL;
main()
{
struct node *tmp,*q;
int i,n,item;
printf(\"Enter the number of elements in the list : \");
scanf(\"%d\", &n);
for(i=0;iinfo=item;
tmp->link=NULL;
if(start==NULL) /* Inserting first element */
start=tmp;
else
{
q=start;
while(q->link!=NULL)
q=q->link;
q->link=tmp;
}
}/*End of for*/
printf(\"Unsorted list is :\ \");
display();
radix_sort();
printf(\"Sorted list is :\ \");
display ();
}/*End of main()*/
display()
{
struct node *p=start;
while( p !=NULL)
{
printf(\"%d \", p->info);
p= p->link;
}
printf(\"\ \");
}/*End of display()*/
radix_sort()
{
int i,k,dig,maxdig,mindig,least_sig,most_sig;
struct node *p, *rear[10], *front[10];
least_sig=1;
most_sig=large_dig(start);
for(k = least_sig; k <= most_sig ; k++)
{
printf(\"PASS %d : Examining %dth digit from right \",k,k);
for(i = 0 ; i <= 9 ; i++)
{
rear[i] = NULL;
front[i] = NULL ;
}
maxdig=0;
mindig=9;
p = start ;
while( p != NULL)
{
/*Find kth digit in the number*/
dig = digit(p->info, k);
if(dig>maxdig)
maxdig=dig;
if(diglink = p ;
rear[dig] = p ;
p=p->link;/*Go to next number in the list*/
}/*End while */
/* maxdig and mindig are the maximum amd minimum
digits of the kth digits of all the numbers*/
printf(\"mindig=%d maxdig=%d\ \",mindig,maxdig);
/*Join all the queues to form the new linked list*/
start=front[mindig];
for(i=mindig;ilink=front[i+1];
else
rear[i+1]=rear[i];
}
rear[maxdig]->link=NULL;
printf(\"New list : \");
display();
}/* End for */
}/*End of radix_sort*/
/* This function finds number of digits in the largest element of the list */
int large_dig()
{
struct node *p=start ;
int large = 0,ndig = 0 ;
while(p != NULL)
{
if(p ->info > large)
large = p->info;
p = p->link ;
}
printf(\"Largest Element is %d , \",large);
while(large != 0)
{
ndig++;
large = large/10 ;
}
printf(\"Number of digits in it are %d\ \",ndig);
return(ndig);
} /*End of large_dig()*/
/*This function returns kth digit of a number*/
int digit(int number, int k)
{
int digit, i ;
for(i = 1 ; i <=k ; i++)
{
digit = number % 10 ;
number = number /10 ;
}
return(digit);
}/*End of digit()*/
Solution
/* Program of sorting using shell sort */
#include
#define MAX 20
main()
{
int arr[MAX], i,j,k,n,incr;
printf(\"Enter the number of elements : \");
scanf(\"%d\",&n);
for(i=0;i=1)
{
for(j=incr;j= 0 && k < arr[i]; i = i-incr)
arr[i+incr]=arr[i];
arr[i+incr]=k;
}
printf(\.
Implementing Software Machines in Go and CEleanor McHugh
Early draft of a tutorial on techniques for implementing virtual machines and language interpreters. Contains example programs for functional stacks and despatch loops.
How do you stop infinite loop Because I believe that it is making a.pdffeelinggift
How do you stop infinite loop? Because I believe that it is making an infinite circular list.
c++ code:
Here is the list class:
#ifndef LIN_J_LIST
#define LIN_J_LIST
typedef unsigned int uint;
#include
#include
using namespace std;
/**
* a simplified generic singly linked list class to illustrate C++ concepts
* @author Jerry Lin
* @version 2/17/17
*/
template< typename Object >
class List
{
private:
/**
* A class to store data and provide a link to the next node in the list
*/
class Node
{
public:
/**
* The constructor
* @param data the data to be stored in this node
*/
explicit Node( const Object & data )
: data{ data }, next{ nullptr } {}
Object data;
Node * next;
};
public:
/**
* The constructor for an empty list
*/
List()
: size{ 0 }, first{ nullptr }, last{ nullptr } {}
/**
* the copy constructor-creates and copy the list
*/
List( List && rhs ) = delete;
List( const List & rhs )
{
count = 0;
size = 0;
if(rhs.size != 0)
{
push_front(rhs.front());
Node * current = rhs.first;
Node * tempNode = first;
size++;
while(current->next != nullptr)
{
current = current->next;
Node *newNode = new Node(current->data); //transfer the data. basic op.
count++;
tempNode->next = newNode;
last = newNode;
tempNode = tempNode->next;
size++;
}
}
// you document and implement this method
}
/**
* the operator= method-copies the list
*/
List & operator=( List && rhs) = delete;
List & operator=( const List & rhs )
{
count = 0;
size = 0;
if( size != 0 )
{
Node * current = first;
Node * temp;
while( current != nullptr )
{
temp = current;
current = current->next;
delete temp;
}
}
if(rhs.size!= 0)
{
push_front(rhs.front());
Node * current = rhs.first;
Node * tempNode = first; //create a temporary to store
size++;
while(current -> next != nullptr)
{
current = current->next;
Node *newNode = new Node(current->data); //transfer the data. basic op
count++;
tempNode->next = newNode;
last = newNode;
tempNode = tempNode -> next;
size++;
}
}
return *this;
// you document and implement this method
}
/**
* accessor
* @return count
*/
int get_count() const
{
return count;
}
/**
* The destructor that gets rid of everything that\'s in the list and
* resets it to empty. If the list is already empty, do nothing.
*/
~List()
{
if( size != 0 )
{
Node * current = first;
Node * temp;
while( current != nullptr )
{
temp = current;
current = current->next;
delete temp;
}
}
}
/**
* Put a new element onto the beginning of the list
* @param item the data the new element will contain
*/
void push_front( const Object& item )
{
Node * new_node = new Node( item );//basic op.
if(is_empty())
{
last = new_node;
}
else
{
new_node->next = first;
}
first = new_node;
size++;
/* you complete the rest */
}
/**
* Remove the element that\'s at the front of the list. Causes an
* assertion error if the list is empty.
*/
void pop_front()
{
assert( !is_empty() );
Node * temp = first;
if( first == last )
{
first = last = nullptr;
}
else
{
first = first->next;
}
delete temp;
size--;
}
/**
* Accessor to return the da.
Please fill in the code to run the program based on the following in.pdfamarnathmahajansport
Please fill in the code to run the program based on the following instructions(Please make sure it
compiles and runs and gives output in the given format):
(Please note that I don't need an explanation for the code, but the code itself. Thanks in advance)
Input: Take a filed named topo.txt as an input, the contents of the file is below
0 10 5 2
10 0 1 1
5 1 0 3
2 1 3 0
Your simulator should read a topology file (say, topo.txt) with a matrix {Di,j }, i, j {0.., N 1}. N
is the number of nodes (routers) and Di,j is the link cost from node i to node j. If nodes i and j are
the same, Di,j = 0; If nodes i and j are directly connected (adjacent), Di,j = e, where e 0.
Otherwise, nodes i and j are not directly connected and you should assign link cost Di,j = 1.
Implementation:
You need to first implement DV initialization per node via rtinit(struct distance table *dt, int
node id, int *link costs, int num nodes)
For every node, rtinit() will be called only ONCE at the beginning of the simulation (k=0). For
example, to initialize node 0, you need to use rtinit(&dt, 0, link cost, 4) (Please check the sample
code for more information). Node 0 should firstly initialize its distance table by setting all
distances to 1. After that, node 0s distance vector in the distance table is changed to (0,10,5,2),
representing the minimum distance from node 0 to all nodes in the topology. Lastly, node 0
needs to send its distance vector in a routing packet to its connected neighbors using
send2neighbor(rtpkt packet) (you can find this function in the sample code) based on the input
topology.
You then need to implement DV update for each received routing packets. Please assume that
every DV update happens in a synchronous manner while it is not true for DV in reality.
Please use this method to update DV for each node- rtupdate(struct distance table *dt, struct rtpkt
recv pkt)
This method will be called for each received routing packet at each simulation time slot k 1. It
parses the input, which is a routing packet recv pkt to update the distance table based on the DV
algorithm. If its own minimum distance to any of the other nodes is updated, the node informs its
directly connected neighbors of this change in minimum cost by sending them a routing packet
(send2neighbor(rtpkt packet)). Therefore, in the given example, nodes 0 and 1 will communicate
with each other, but nodes 1 and 3 will not.
Convergence: Please make sure that your code can run successfully and produce correct and
converged output under any topology with any N 10.
Test cases and the expected outputs:
Assume the simulation starts at slot k = 0 for initialization and k 1 when updating DVs at each
simulation slot. You need to print out the current slot k followed by DVs of all the nodes in the
ascending order at the end of the simulation slots. Please print them out in the first five slots (k =
0, 1, 2, 3, 4) and then every 10 slots (k = 10, 20, 30, ) until they converge. In this test case, the
expected out.
This is a c++ binary search program I worked so far but still cant g.pdfkostikjaylonshaewe47
This is a c++ binary search program I worked so far but still cant get it right.
Can anyone help me? Big thanks!!
the client should not be modified
/*
*File: client.cpp
*Author: Yingwu Zhu
*Warning: do not change this file and use it as is.
*Last Modififcation: 10/21/2016
*/
#include
#include
#include
#include
#include
#include \"bst.h\"
using namespace std;
int main(int argc, char* argv[]) {
if (argc != 2) {
cout << \"Format: \" << argv[0] << \" [data file]\" << endl;
return 0;
}
ifstream fin(argv[1]);
int cases;
fin >> cases;
int passed = 0;
for (int i = 1; i <= cases; i++) {
cout << \"Checking test case #\" << i << \" ... \";
BST T;
set S;
int n, x;
fin >> n;
bool ok = true;
vector tmp;
int rem = 0;
for (int j = 0; j < n; j++) {
fin >> x;
T.Insert(x);
S.insert(x);
ok &= (T.Search(x) && T.RecurSearch(x));
if (tmp.empty())
tmp.push_back(x);
if (rand()%10 < 3) {
T.Erase(tmp[0]);
S.erase(tmp[0]);
ok &= (T.Search(tmp[0]) == false);
tmp.pop_back();
rem++;
}
}
if (rem
ok &= (T.MaxElement() == *S.rbegin());
while (!S.empty() && !T.Empty()) {
int x = T.MinElement();
ok &= (x == *S.begin());
T.Erase(x);
S.erase(S.begin());
}
cout << (ok ? \"Passed!\" : \"Failed\") << endl;
passed += ok;
}
cout << passed << \" of \" << cases << \" test cases have passed!\ \";
if (passed == cases)
cout << endl << \"Congratulations! Good to Submit Your Code\ \";
else if ((double)passed/cases >= 0.95)
cout << endl << \"You are almost there, but need to fix some bugs.\ \";
else
cout << endl << \"Your code needs a lot of fixes for submission\ \";
return 0;
}
=====================================================================
=======
//bst.h
#ifndef _BST_H_
#define _BST_H_
#include
using namespace std;
class BST {
private:
class Node {
public:
int data;
Node* left;
Node* right;
};
Node* root; //root node pointer
//you may add your auxiliary functions here!
public:
BST(); //constructor
~BST(); //destructor
bool Empty() const;
void Insert(int val);
int MinElement() const;
int MaxElement() const;
bool Search(int val) const;
bool RecurSearch(int val) const;
void Erase(int val);
};
#endif
=====================================================================
=======
/*
bst.cpp
Subject: Binary Seach Tree
Modification Time:10/26/2016
*/
#include
#include\"bst.h\"
using namespace std;
BST::BST(){
root= NULL;
}
BST::~BST(){
delete root;
delete root->left;
delete root->right;
}
bool BST::Empty() const {
return data;
}
void BST::Insert(int val){
Node* p= new Node;
p->data= val;
Node* cur = root;
if(val < cur->data){
cur = cur -> left;
}
else{
right->next=val;
}
}
int BST::MinElement() const {
Node* cur;
while(cur->left != NULL){
cur = cur->left;
}
return(cur->data);
}
int BST::MaxElement() const{
if(root==NULL){
return 0;
}
if(root->left>root->data){
root->data=root->right;
}
else if(root->right>root->data){
root->data=root->right;
}
return root->data;
}
bool BST:: Search(int val) const{
Node* cur;
cur = root;
while(cur!=NULL){
if(cur->data == val){
return true;
}
else if(cur->data .
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
Even though at surface level ‘java.lang.OutOfMemoryError’ appears as one single error; underlyingly there are 9 types of OutOfMemoryError. Each type of OutOfMemoryError has different causes, diagnosis approaches and solutions. This session equips you with the knowledge, tools, and techniques needed to troubleshoot and conquer OutOfMemoryError in all its forms, ensuring smoother, more efficient Java applications.
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
Data privacy is one of the most critical issues that businesses face. This presentation shares insights on the principles and best practices for ensuring the resilience and security of your workload.
Drawing on a real-life project from the HR industry, the various challenges will be demonstrated: data protection, self-healing, business continuity, security, and transparency of data processing. This systematized approach allowed to create a secure AWS cloud infrastructure that not only met strict compliance rules but also exceeded the client's expectations.
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Hivelance Technology
Cryptocurrency trading bots are computer programs designed to automate buying, selling, and managing cryptocurrency transactions. These bots utilize advanced algorithms and machine learning techniques to analyze market data, identify trading opportunities, and execute trades on behalf of their users. By automating the decision-making process, crypto trading bots can react to market changes faster than human traders
Hivelance, a leading provider of cryptocurrency trading bot development services, stands out as the premier choice for crypto traders and developers. Hivelance boasts a team of seasoned cryptocurrency experts and software engineers who deeply understand the crypto market and the latest trends in automated trading, Hivelance leverages the latest technologies and tools in the industry, including advanced AI and machine learning algorithms, to create highly efficient and adaptable crypto trading bots
Experience our free, in-depth three-part Tendenci Platform Corporate Membership Management workshop series! In Session 1 on May 14th, 2024, we began with an Introduction and Setup, mastering the configuration of your Corporate Membership Module settings to establish membership types, applications, and more. Then, on May 16th, 2024, in Session 2, we focused on binding individual members to a Corporate Membership and Corporate Reps, teaching you how to add individual members and assign Corporate Representatives to manage dues, renewals, and associated members. Finally, on May 28th, 2024, in Session 3, we covered questions and concerns, addressing any queries or issues you may have.
For more Tendenci AMS events, check out www.tendenci.com/events
Strategies for Successful Data Migration Tools.pptxvarshanayak241
Data migration is a complex but essential task for organizations aiming to modernize their IT infrastructure and leverage new technologies. By understanding common challenges and implementing these strategies, businesses can achieve a successful migration with minimal disruption. Data Migration Tool like Ask On Data play a pivotal role in this journey, offering features that streamline the process, ensure data integrity, and maintain security. With the right approach and tools, organizations can turn the challenge of data migration into an opportunity for growth and innovation.
Advanced Flow Concepts Every Developer Should KnowPeter Caitens
Tim Combridge from Sensible Giraffe and Salesforce Ben presents some important tips that all developers should know when dealing with Flows in Salesforce.
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
Why React Native as a Strategic Advantage for Startup Innovation.pdfayushiqss
Do you know that React Native is being increasingly adopted by startups as well as big companies in the mobile app development industry? Big names like Facebook, Instagram, and Pinterest have already integrated this robust open-source framework.
In fact, according to a report by Statista, the number of React Native developers has been steadily increasing over the years, reaching an estimated 1.9 million by the end of 2024. This means that the demand for this framework in the job market has been growing making it a valuable skill.
But what makes React Native so popular for mobile application development? It offers excellent cross-platform capabilities among other benefits. This way, with React Native, developers can write code once and run it on both iOS and Android devices thus saving time and resources leading to shorter development cycles hence faster time-to-market for your app.
Let’s take the example of a startup, which wanted to release their app on both iOS and Android at once. Through the use of React Native they managed to create an app and bring it into the market within a very short period. This helped them gain an advantage over their competitors because they had access to a large user base who were able to generate revenue quickly for them.
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.