Kingdom of Saudi Arabia
Ministry of Higher Education
Majmaah University
ةـيدوـعـسـلا ةـيـبرـعـلا ةـكلـمـمـلا
يـلاـعـلا مـيـلـعـتـلا ةرازو
ةـعـمـجـمـلا ةـعـماـج
يفلزلاب مولعلا ةيلك
College Of Sciences in Alzulfi
: ىوتسملا CSI 312 : ةداملا زمرو مقر تانايبلا بيكارت : ةداملا مسا
1436 / 1 / 2 : ناحتملإا خيرات : يعماجلا مقرلا : بلاطلا مسا
Answer the following questions:
Consider the linked list shown in Figure, assume that a linked list is made up of nodes, pointers are defined as follows: struct Node{ int info;
Node *link;
};
Node *list, *A, *B;
Use this list to answer questions 1 and 2. list 18
A
32 23 16 43
B
87
Question 1
What is the output for each of the following C++ statements?
25 44 a. cout << list->info; b. cout << B->link->info; c. cout << list->link->link->info;
1
Kingdom of Saudi Arabia
Ministry of Higher Education
Majmaah University
ةـيدوـعـسـلا ةـيـبرـعـلا ةـكلـمـمـلا
يـلاـعـلا مـيـلـعـتـلا ةرازو
ةـعـمـجـمـلا ةـعـماـج
يفلزلاب مولعلا ةيلك
College Of Sciences in Alzulfi
: ىوتسملا CSI 312 : ةداملا زمرو مقر تانايبلا بيكارت : ةداملا مسا
1436 / 1 / 2 : ناحتملإا خيرات : يعماجلا مقرلا : بلاطلا مسا
Question 2
Write C++ statements to do the following: a. Make A point to the node containing info 23. b. Make this linked list is an empty list. c. Update the value of the node containing 25 to 35. d. Create a newNode with info 10. e. insert the newNode after the node pointed to by A.
3- Write a C++ program that use a structure for books in a library, each book has 3 fields: a title, publication year, and number of pages. Use an array to enter a group of 10 books, then print the data for each book.
2