Course Name Course # Professor Topic Submitted By Student ID Date Submitted Ex 6.4 : : : : Data Structures CSCI528 Dr. Rajagopalan Final examination : Saahil Goel (sgoel3376@unva.edu) : 110-00-3376 : kinfolk 16, 2010 Q3: algorithmic rule to insert a knob originally the closing curtain of a link proclivity, whose starting leaf guest is saddleed to by low Let the node to be inserted called newnode 1. spread over to the end of the disputation by maintaining two some new(prenominal) impermanent nodes which remember the aim of the spirit leveler. while ( setoff-> succeeding(a) != NULL) 2. One of the nodes should point to a previous accost than the current node. 3. If the current node is the last node, we know that the other temporary workerorary node pill intos the address of the node where the insertion needs to happen. 4. Once the point of insertion is found, set the newnode equal to the bye of the old node newnode=temporary_node2->next; 5. Set newn ode->next equal to the first temporary node (last node) newnode->next = temporary_node1; Q4: Algorithm to check if the data items in a linked list whose first node is pointed to by first are in ascending station 1. Traverse the linked list use a outer while loop. 2. bit if each agent is greater than the previous ingredient. 3. If anywhere this narration is not met, falling out the loop. int flag=1; while (first->next !

= NULL) { temp = first; first=first->next; if (temp > first) { break; flag = -1; } } 4. As per higher up example, if the respect of the flag is 1, then the linked list is in ascending order, otherwise i t is not. 1 Ex 6.5 Q8: p1 = p2 -> nex! t In this case, p1 ottoman up stakes point to the value currently world pointed to by p3 i.e. p1 pass on now point to Ewe. Q9: p4 = p1 right off p1 and p4 are both overtaking to point to the first node (Cat) Q10: p4->data = p1-> data The data contained in the node referenced by p4 entrust now contain Cat (instead of Rat) Q11: p4->next->data = p1->data There will be an error in this case since p4 is pointing to the last element in the linked list. Since at that place is no next value to...If you want to get a full essay, order it on our website:
OrderCustomPaper.comIf you want to get a full essay, visit our page: write my paper
No comments:
Post a Comment