Docsity

PPT for com sci component 1, Lecture notes of Computer Science

Toggle sidebar
bg1
1. A database management system presents data in a table. It also stores hidden secondary keys as linked lists to
quickly output the data sorted by either the Name or Rank fields. Complete the abstraction of the pointers in
the linked lists by joining the keys to the indexes with arrows. The first few have been done for you as an
example.
The following structures to store data:
โ— linked list โ— graph (directed and undirected) โ— stack โ— queue โ— tree โ— binary search tree โ— hash
table
Data structures
Inde
x
Name Rank Name
Key
Rank
Key
Root at 0 Root at
2
0 Chris C 2 1
1 Georg
e
D 3 Null
2 Dan A 1 3
3 Jane B Null 0
Inde
xName Ran
k
Nam
e
Key
Ran
k
Key
0 Chris C 2 1
Name
Rank
Inde
xName Ran
k
Nam
e
Key
Ran
k
Key
1Georg
eD 3 Null
Inde
xName Ran
k
Nam
e
Key
Ran
k
Key
2 Dan A 1 3
Inde
xName Ran
k
Nam
e
Key
Ran
k
Key
3 Jane B Null 0
pf3
pf4
pf5

Partial preview of the text

Download PPT for com sci component 1 and more Lecture notes Computer Science in PDF only on Docsity!

1. A database management system presents data in a table. It also stores hidden secondary keys as linked lists to

quickly output the data sorted by either the Name or Rank fields. Complete the abstraction of the pointers in

the linked lists by joining the keys to the indexes with arrows. The first few have been done for you as an

example.

The following structures to store data: โ— linked list โ— graph (directed and undirected) โ— stack โ— queue โ— tree โ— binary search tree โ— hash table Inde x Name Rank Name Key Rank Key Root at 0 Root at 2 0 Chris C 2 1 1 Georg e D 3 Null 2 Dan A 1 3 3 Jane B Null 0 Inde x Name Ran k Nam e Key Ran k Key 0 Chris C 2 1 Name Rank Inde x Name Ran k Nam e Key Ran k Key 1 Georg e D 3 Null Inde x Name Ran k Nam e Key Ran k Key 2 Dan A 1 3 Inde x Name Ran k Nam e Key Ran k Key 3 Jane B Null 0

1. State and explain one advantage and one disadvantage of the linked list data structure.

The following structures to store data: โ— linked list โ— graph (directed and undirected) โ— stack โ— queue โ— tree โ— binary search tree โ— hash table Advantage Disadvantage

Answer: Answer:

Explanation: Explanation:

2. State the other data structures you could implement using a linked list.

2. Explain the order of the items in the array, and why they are not sorted by name.

How to create, traverse, add data to and remove data from data structures, either using arrays and procedural programming or an object-oriented approach Ite m Name Alpha pointers 0 Jim 5 1 Jane 0 2 Claud 1 3 Steven 4 4 Tony 5 Liam 3 6 7 7 8 8

  1. A linked list is implemented using an array. Update the visualisation to show the effect of removing Jim while

maintaining a logical alphabetical order to the items within the structure. Do not move any of the boxes.

How to create, traverse, add data to and remove data from data structures, either using arrays and procedural programming or an object-oriented approach Ite m Name Alpha pointers 0 Jim 3 1 Jane 0 2 Claud 1 3 Steven 4 4 Tony 5 6 6 7 7 8 8

Start at 2 Free is at 5

Alphabetic pointer

starts at 2

Jim 3 Jane 0 Claud 1 Steven 4 Tony

5 free 6 free 7 free 8 free

Free

point

er

1. Arrange the pseudocode to delete an item to a linked list maintaining an order to the items in the structure. For

clarity, sequences are shaded grey, selections are shaded blue, and iterations are shaded yellow. You should

indent code inside selection statements.

How to create, traverse, add data to and remove data from data structures, either using arrays and procedural programming or an object-oriented approach

If the list is empty, output an error.

If the first node is the one to delete, then:

Set the start pointer to the second node.

If the node to delete is not the first node, then starting from the first node:

Find the position of the node to be deleted by repeatedly checking if the current node is the one to

delete.

If not, follow the pointer to the next node.

Set the pointer of the previous node to point to the next node.