The Importance of Data Structures in AI
Primitive Data Structures
Non-Primitive Data Structures
Different types of data
Linear Data Structures
Stack
Last In First Out (LIFO) rule
Operations on the stack
Push Operation
Pop Operation
Stack in Python
The push operation of the stack is
Jupyter Notebook
To create a new Jupyter Notebook:
To create a program in Jupyter Notebook:
Let's see the example of figure 1.15 in Jupyter.
In the following program, you will create a stack
Execute the previous program as follows:
Queue
Operations on the Queue:
First In First Out (FIFO) rule
The difference between the stack
Pointer
Index
Figure 1.22: Operations on the Queue
Enqueue Operation
Dequeue Operation
Queue in Python
Table 1.4: listName.pop() vs listName.pop(0) method
To program the above steps in Python,
Queue Applications
Stack and Queue Using Queue Module
Create a queue in which five values are entered by the user during program execution,
As mentioned before, the Queue module includes
You can use the following algorithm:
You can use the following algorithm:2
You can use the following algorithm:3
Static and Dynamic Data Structures
Static Data Structure
Dynamic Data Structure
Memory Allocation
Linked List
Linked List
Node
Figure 1.28: Graphical representation of node
Figure 1.30: Access the third node of the linked list
Table 1.8: Differences between list and linked list
Linked List in Python
Class
You will first create a node using Class.
Now add more nodes to your linked list.
Add a Node to a Linked List The actions required to add the new node
# single node
Delete a Node from a Linked List
If you want to delete the first node of a linked list, you must move the head to the second node of the list.
Read the sentences and tick True or False.
State the differences between static and dynamic data structures.
Write two examples of uses for linked lists.
You have a stack with six empty spaces.
• What is the process used to add the above elements into the queue?
• Complete the queue after adding the elements.
• What is the process used to remove elements from the queue?
How many times should the above operation be performed to remove the element with value 5?
Write Python code to create the previous queue.
Given the following nodes, draw the linked list and then write the values in the list in the correct order.
Draw the nodes of the linked list.
Describe the process of adding the number 7 after the number 45.
Draw the new list.
Describe the process required to delete the second node of the list.
• Draw the final linked list.