computer science data questions

computer science data questions

2. The table following shows a dynamic implementation of a list of characters. Some ofthe locations contain a letter, and each is followed by a location that holds a pointer tothe next letter in the list.Notice that a pointer points to a character. For example, assume there is a pointercalled list pointing to the first character in the list. Say list has the value 62,then the first character is E.0 is used for the NULL pointer.What are the characters in the list in the correct order?Address Contents52- V53 -054- M55 -5856 -T57 -5458- S59 -5260 -W61 -5662 -E63 -60list is: E3. The table following shows a dynamic implementation of a list. The pointer to thefirst item in the list has value 40.What is the list?Address Contents32 -I33 -3834 -P35 -036 -S37 -3438 -S39 -4240 -Q41 -3242 -C43 -36list is: 4. The table following shows the contents of main memory. Put addresses into theempty pointer fields to build a list of the characters in alphabetical order. Use 0 forthe NULL pointer.If a pointer called list is to point to the first letter in the list, what would be thevalue of list?Address Contents40 -N4142- U4344 -B4546 -J4748 -W4950 -F51value of list: 5. Unlike static implementations, deleting items from dynamic data structures isextremely efficient.Given that the list below is to remain in alphabetical order, alter whichever pointersare necessary to delete T. (The list begins with C.)Address Contents14- Y15- 016 -I17 -2018 -T19- 1420 -K21 -1822 -F23 -1624 -C25 -226. Inserting a new item is similarly efficient.Below is the previous list. First cross-out the letter T in the table and write-in theletter H. Now update whatever pointers are necessary to insert H into the list,maintaining the list in alphabetical order. The list begins with C.Address Contents14 -Y15 -016 -I17 -2018 -T19 -1420 -K21 -1822- F23 -1624 -C25 -227. Which of the following pseudocode algorithms correctly inserts a record callednewrecord immediately after the record called currentrecord in a linkedlist?(HINT: to help you solve the problem, draw a picture of a linked list with 3 items,where currentrecord is the middle item. Draw newrecord outside the list,then follow the steps of each algorithm to see how the list is changed.)Algorithm #11. set the pointer field of currentrecord to point to newrecord2. set the pointer field of newrecord to point to the record pointed to bycurrentrecordAlgorithm #21. set the pointer field of newrecord to point to the record pointed to bycurrentrecord2. set the pointer field of currentrecord to point to newrecordcorrect algorithm is: briefly, what is wrong with the other algorithm?8. A record in a dynamic data structure can contain more than one pointer field. Giventhe table following, fill-in the first location after each letter to build a list of the lettersin alphabetical order. Set the second location after each letter so that the letters arefound in reverse alphabetical order. Make sure that each list ends correctly, using 0for the NULL pointer.If the pointer alpha points to the start of the list in alphabetical order and reversepoints to the start of the reverse order list, what are the values of these two pointers?Address Contents30 -Y313233 -C343536- A373839- G404142 -W4344value of alpha is: value of reverse is: 9. Each node in a binary tree can be stored using 3 memory locations. The first holdsthe key value of the node (a letter here), the second contains a pointer to the nodesleft child and the third contains a pointer to the right child. Using this representationmethod, fill-in the pointer fields so that the table represents the tree given below.What should the value of the root pointer be?Address Contents30 -T313233 -Z343536 -S373839- I404142 -R434445 -K4647R/ k t/ / i s zValue of root pointer is:


Comments are closed.