Docsity

Programming Code, Lab Quiz - Data Structures and Algorithms | ECE 2574, Quizzes of Data Structures and Algorithms

Partial preview of the text

Download Programming Code, Lab Quiz - Data Structures and Algorithms | ECE 2574 and more Quizzes Data Structures and Algorithms in PDF only on Docsity!

Quiz 2 ECE 2574 40 Your Name: {Please DO NOT put your Hokie ID on this paper, and please use your name as it appears on your VT hokie passport) Consider the following code fragment: using namespace std; typedef int listItemType; struct listNode // a node on the list { listItemType Item; // a data item on the list ptrType Next; // pointer to next node 3; // end struct typedef listNode* ptrType; int main() { ptrType Head; Head = new listNode; if (Head 1!= NULL) { // check allocation Head->Item = 4; Head->Next = new listNode; if (Head->Next != NULL) { (Head->Next)->Item = 3; (Head->Next}->Next = new listNode; } if ((Head->Next)->Next != NULL) { { (Head->Next) ->Next)->Item = 3; ( (Head->Next) ->Next)->Next = NULL; // vest of the code here } a. What are the elements in the list created when the code listed above executes? Write down the sequence of numbers as it appears in the list from the beginning to the end of S Fack the list. Heaps fed} ——s pay} ST 4-13 ]X|