Sorting Algorithms
08/29/2018
Running head: LEARNING DATA STRUCTURES 3
LEARNING DATS STRUCTURES 3
Through the length of this course, we will be using this document to portray different data structures and the method of implementation, with reference to the pseudo code of these methods
or data structures We will also become familiar with the pros and cons of these methods. Each week will cover different elements of the Java language, When the five weeks come to an end we
should have better understanding how this all flow together
Table of Contents
Section 1
Lists, Stacks and Queues
Stacks............................................................................................................................................4
Queues..........................................................................................................................................5
Conclusion.....................................................................................................................................6
Section 2
Heaps and Trees Insert................................................................................................................................................7
Remove............................................................................................................................................8
Section 3
Sorting Algorithms..................................................................................................................9
References......................................................................................................................................11
LEARNING DATA STRUCTURES 3
Lists, Stacks, and Queues
Stack
The stack executed utilizing a linked list can work for boundless number of qualities. That implies, stack actualized utilizing connected rundown works for variable size of information. Along these lines, there is no compelling reason to settle the size toward the start of the usage. The Stack actualized utilizing connected rundown can compose the same number of information esteems as we need. (Lenka, 2018)
1. Push (thing)
In case next = (max) hurl full stack exceptional case
Stack (next) = thing
Next++
2. Pop ()
If (next == 0)
Toss void stack special case
Next—
Return stack (next)
3. Show ()
If stack = invalid
By then Display (botch message)
Queue
Like a stack, a queue is a direct information structure. Not at all like a stack, a queue erases just the most seasoned included information. To enable you to conceptualize how this would function, how about we pause for a minute to utilize a relationship. Envision a line being fundamentally the same as the ticketing arrangement of a shop. Every client takes a ticket and is served when their number is called (Jenkov, 2014)
End = 0
MAX = 5
Exhibit Queue [MAX]
Enqueue(item)
On the off chance that End=MAX
Show (Queue is full)
Something else
Add 1 to End
Assuming (thing) is invalid
At that point Dequeue ()
Conclusion
I have learned that stack has five elements or functions. Queue is a function like an order in the way things are going to be placed. Basically, stack is LIFO and Queue is FIFO. Both are considered vital in writing script using JAVA.
Heaps and Trees
MakeHashTable (int 8): HashTable
/Engender hash table with 8 spaces//
n= 0
/set space one at 0//
for (n = 0; n ≤ 7: n++)
{
Hash += key[n]:
Hash += (hash << 7);
Hash ^= (hash >> 0);
}
/regard must be some place in the scope of 0 and 7
Limit install (key, regard)
/Engender install work//
n: = findSlot (key)
on the off chance that slot[n] is whole
return=value
attempt slot[n+1]
/if space is whole return regard and endeavor next opening//
Limit remove(key)
/Engender dynamic limit//
N:= findSlot(key)
In case slot[n] is whole
return //key not found//
o := n
circle
o := (o+1) modulus numSlots
if slot[n] is vacuous
leave circle
p := hash(slot[o].key) modulus numSlots
if (o > n and (p <= n or p > o)) or
(o < n and (p <= n and p > o))
slot[n] := slot[o]
I := o
check slot[n] as vacuous
References:
Arora, I. (2015). Implementing our Own Hash Table with Separate Chaining in Java - GeeksforGeeks. [online] GeeksforGeeks. https://www.geeksforgeeks.org/implementing-our-own-hash-table-with-separate-chaining-in-java/
Jenkov, J. (2014). Java Collections - Queue. [online] Tutorials.jenkov.com. http://tutorials.jenkov.com/java-collections/queue
Lenka, C. (2018). Stack Class in Java - GeeksforGeeks. [online] GeeksforGeeks :https://www.geeksforgeeks.org/stack-class-in-java/