Wednesday, February 27, 2013

Finals

Course Name Course # Professor Topic Submitted By Student ID Date Submitted Ex 6.4

: : : :

Data Structures CSCI528 Dr. Rajagopalan Final Exam

: Saahil Goel (sgoel3376@unva.edu) : 110-00-3376 : kinfolk 16, 2010

Q3: Algorithm to insert a node before the closing curtain of a link proclivity, whose starting node is pointed to by low Let the node to be inserted called newnode 1. Traverse to the end of the list by maintaining two some other impermanent nodes which remember the aim of the pointer. while (first->next != 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 check 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 newnode->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 order 1. Traverse the linked list using a outer while loop. 2. bit if each element is greater than the previous element. 3. If anywhere this narration is not met, break the loop. int flag=1; while (first->next !

Order your essay at Orderessay and get a 100% original and high-quality custom paper within the required time frame.

= NULL) { temp = first; first=first->next; if (temp > first) { break; flag = -1; } } 4. As per higher up example, if the value of the flag is 1, then the linked list is in ascending order, otherwise it is not.

1

Ex 6.5 Q8: p1 = p2 -> next In this case, p1 pull up stakes point to the value currently being pointed to by p3 i.e. p1 pass on now point to Ewe. Q9: p4 = p1 Now 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 will 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: Orderessay



If you want to get a full essay, wisit our page: write my essay .

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.