05 - LINKED LIST & 07 - Linked stack & 08 - Linked Queue

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

contiguous

(adj.) side by side, touching; near; adjacent in time

most famous methods in Linked Queue are

- isFull - isEmpty - enqueue - inqueue - firsOne - isOne - isTwo

most famous methods in Linked stack are

- isFull - isEmpty - push - pop - peak - toString

- toString mention the code for the Linked stack

@Override public String toString(){ String str = ""; for (Node k = top ; k!=null ; k=k.next){ str += k.element+" - "; } return str; }

Types of linked lists

Singly, Singly circular and Doubly linked list

self-referential ( A node is called a self-referential object, because it contains a pointer to a variable of the same type. )

a text that makes reference to itself

- isEmpty

boolean isEmpty(){ return (front == null && rear == null); }

isEmpty mention the code for the Linked stack

boolean isEmpty(){ return top == null ; }

- isFull

boolean isFull(){ return false ; }

- isFull mention the code for the Linked stack

boolean isFull(){ return false; } // it's always false because the linked stack can't be full

- isOne

boolean isOne(){ return front == rear; }

- isTwo

boolean isTwo(){ return front.next == rear; // or we can use Size == 2 ; }

- dequeue

int deQueue(){ int x=0; if (!isEmpty()){ x = front.element; front = front.next; size--; } else{ System.out.println("There is no data "); } if (front == null){ rear = null; } return x; } // if the front = null the rear have to equal null too

- firsOne

int firstOne(){ if(!isEmpty()){ return front.element; } else{ System.out.println("it's Empty "); } return -1; }

- peak mention the code for the Linked stack

int peak(){ if (!isEmpty()){ return top.element; } System.out.println("it's Empty"); return -1 ; } why it's have a return value

- pop

int pop(){ int popedValue = -1; if (!isEmpty()){ popedValue = top.element ; top.next = top; size--; } else { System.out.println("this stack is Empty"); } return popedValue; } why it's have a return value ?

what's the purpose of Date structure

organza the information inside the memories

peak

the top of a mountain

traverse ( We must begin from the head of the list and traverse the list sequentially to access the nodes in the list. )

to pass over, across, or through

A Circular Linked List is a special type of Linked List

true

Circular Linked List supports traversing from the end of the list to the beginning by making the last node point back to the head of the list

true

If the list is empty, then the head has the value NULL.?

true

In the singly linked list the traversal is allowed only one way and there is no going back.?

true

We must begin from the head of the list and traverse the list sequentially to access the nodes in the list.?

true

- enqueue

void enQueue(int e){ Node n = new Node(e); if(!isEmpty()){ rear.next = n ; rear = rear.next ; // or rear=n; } else { front = n ;rear = n; } size++; }

push mention the code for the Linked stack

void push(int e){ Node n = new Node(e); n.next=top; top = n ; size++ ; }


Ensembles d'études connexes

Palabras con diptongos ai (ay), ei (ey), iu, oi (oy), ui (uy)

View Set

1.05: Analyze a Speaker's Argument

View Set

FCE Use of English Part 2 (Open Cloze)

View Set

ICORE Leadership/Management (Z370)

View Set

Research Methods Naturalistic Observations

View Set

Government Quiz: Forms of Government

View Set