Skip to content

Commit dbf8e3a

Browse files
committed
2 parents e808e8c + 9587092 commit dbf8e3a

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,63 @@
1-
# Data-Strcture-Algorithm-using-Python
1+
# Data-Strcture-Algorithm-using-Python
2+
3+
4+
Topics:
5+
* Queues
6+
* Stacks
7+
* Doubly Linked Lists
8+
* Singly Linked Lists
9+
* Binary Search Trees
10+
* Tree Traversal
11+
* Sortings
12+
* Searchings
13+
* Dynamic Programming
14+
* Heap
15+
* Graph
16+
17+
### Queues
18+
* Should have the methods: `enqueue`, `dequeue`, and `len`.
19+
* `enqueue` should add an item to the back of the queue.
20+
* `dequeue` should remove and return an item from the front of the queue.
21+
* `len` returns the number of items in the queue.
22+
23+
24+
![Image of Queue](https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Data_Queue.svg/600px-Data_Queue.svg.png)
25+
26+
### Doubly Linked Lists
27+
* The `ListNode` class, which represents a single node in the doubly-linked list, has already been implemented for you. Inspect this code and try to understand what it is doing to the best of your ability.
28+
* The `DoublyLinkedList` class itself should have the methods: `add_to_head`, `add_to_tail`, `remove_from_head`, `remove_from_tail`, `move_to_front`, `move_to_end`, `delete`, and `get_max`.
29+
* `add_to_head` replaces the head of the list with a new value that is passed in.
30+
* `add_to_tail` replaces the tail of the list with a new value that is passed in.
31+
* `remove_from_head` removes the head node and returns the value stored in it.
32+
* `remove_from_tail` removes the tail node and returns the value stored in it.
33+
* `move_to_front` takes a reference to a node in the list and moves it to the front of the list, shifting all other list nodes down.
34+
* `move_to_end` takes a reference to a node in the list and moves it to the end of the list, shifting all other list nodes up.
35+
* `delete` takes a reference to a node in the list and removes it from the list. The deleted node's `previous` and `next` pointers should point to each afterwards.
36+
* `get_max` returns the maximum value in the list.
37+
* The `head` property is a reference to the first node and the `tail` property is a reference to the last node.
38+
39+
![Image of Doubly Linked List](https://upload.wikimedia.org/wikipedia/commons/thumb/5/5e/Doubly-linked-list.svg/610px-Doubly-linked-list.svg.png)
40+
41+
### Binary Search Trees
42+
* Should have the methods `insert`, `contains`, `get_max`.
43+
* `insert` adds the input value to the binary search tree, adhering to the rules of the ordering of elements in a binary search tree.
44+
* `contains` searches the binary search tree for the input value, returning a boolean indicating whether the value exists in the tree or not.
45+
* `get_max` returns the maximum value in the binary search tree.
46+
* `for_each` performs a traversal of _every_ node in the tree, executing the passed-in callback function on each tree node value. There is a myriad of ways to perform tree traversal; in this case any of them should work.
47+
48+
![Image of Binary Search Tree](https://upload.wikimedia.org/wikipedia/commons/thumb/d/da/Binary_search_tree.svg/300px-Binary_search_tree.svg.png)
49+
50+
### Heaps
51+
* Should have the methods `insert`, `delete`, `get_max`, `_bubble_up`, and `_sift_down`.
52+
* `insert` adds the input value into the heap; this method should ensure that the inserted value is in the correct spot in the heap
53+
* `delete` removes and returns the 'topmost' value from the heap; this method needs to ensure that the heap property is maintained after the topmost element has been removed.
54+
* `get_max` returns the maximum value in the heap _in constant time_.
55+
* `get_size` returns the number of elements stored in the heap.
56+
* `_bubble_up` moves the element at the specified index "up" the heap by swapping it with its parent if the parent's value is less than the value at the specified index.
57+
* `_sift_down` grabs the indices of this element's children and determines which child has a larger value. If the larger child's value is larger than the parent's value, the child element is swapped with the parent.
58+
59+
![Image of a Heap in Tree form](https://upload.wikimedia.org/wikipedia/commons/thumb/3/38/Max-Heap.svg/501px-Max-Heap.svg.png)
60+
61+
![Image of a Heap in Array form](https://upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Heap-as-array.svg/603px-Heap-as-array.svg.png)
62+
63+

0 commit comments

Comments
 (0)