0% found this document useful (0 votes)
22 views37 pages

ADTs

CS Notes

Uploaded by

jokante1151
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views37 pages

ADTs

CS Notes

Uploaded by

jokante1151
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

AS & A LEVEL COMPUTER SCIENCE 9618

ABSTRACT DATA TYPES (ADTs)


An ADT is a collection of data and a set of operations on that dat.
Examples of Abstract Data Types
1. Queue
2. Stack
3. Linked List
STACKS

A stack is a list containing several items operating using last-in-first out (LIFO)
principle. Items can be added to the stack(PUSH) and can be removed from the
stack (POP).
The first item added to the stack is the last the last one to removed from the stack

1 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

STACKS

T.P T.P
T.P

B.P
B.P B.P

T.P ----------> Top Pointer B.P ---------->Base Pointer

Note : Stack can be implemented using an array and a set of pointers

2 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

STACK IMPLEMENTATION

3 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

STACKS

4 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

STACKS

5 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

STACKS

6 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

STACKS

7 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

QUEUES
A list containing several items operating on the first in first out (FIFO) principle. The
first item added is the first item to be removed from the queue

F.T
F.T F.T

R.T R.T
R.T

F.T ----------> Front Pointer R.T ----------> Rear Pointer

8 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

QUEUES DESCRIPTION
1. Linear data structure
2. First-In-First-Out- Item added in first is the first one to be removed
3. Items are kept in the order they are entered
4. Has a head pointer and tail pointer

9 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

LINKED LIST
A list containing several items in which the first item in the list points to the next
item in the list. In a linked list a new item is always added at the start of the list.

10 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

Adding new node at the beginning of the list

11 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

Adding New Node At The End Of The Linked List

12 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

Deleting the first node from the list

13 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

Deleting the last node from the list

14 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

Adding a new node in between the list

15 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

Deleting a node from within the linked list

16 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

Implement a linked list using an array

17 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

Adding new node at the beginning of the list

18 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

Adding new node at the beginning of the list

19 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

Adding a new node to the end of a linked list


implemented using arrays

20 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

Deleting the last node of a linked list implemented using arrays

21 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

Adding a new node into a linked list implemented using arrays

22 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

Deleting a node within a linked list implemented using arrays

23 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

How to deal with free nodes within a linked list

24 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

A linked list and a free list implemented using arrays

25 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

A linked list and a free list implemented using arrays continued

26 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

A linked list and a free list implemented using arrays continued

27 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

LINKED LIST PAST PAPERS

28 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

LINKED LIST PAST PAPERS

29 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

LINKED LIST PAST PAPERS

30 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

LINKED LIST WITH STACKS

31 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

LINKED LIST WITH STACKS

32 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

LINKED LIST WITH STACKS

33 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

LINKED LIST WITH A QUEUE

34 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

LINKED LIST WITH A QUEUE

35 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

LINKED LIST WITH A QUEUE

36 Davis_Kazibwe@2023KIS
AS & A LEVEL COMPUTER SCIENCE 9618

LINKED LIST WITH A QUEUE

37 Davis_Kazibwe@2023KIS

You might also like