├── JavaFirst.java ├── testGenericClass.java ├── stack.java ├── Main_Postfix_Eval.java ├── stackArray.java ├── testBSTree.java ├── stackAsLinkedList.java ├── testArray.java ├── array_lab.java ├── singlyLinkedList.java ├── testAVLTree.java └── README.md /JavaFirst.java: -------------------------------------------------------------------------------- 1 | class JavaFirst { 2 | public static void main(String[] args) { 3 | System.out.println("Hello World"); 4 | } 5 | } -------------------------------------------------------------------------------- /testGenericClass.java: -------------------------------------------------------------------------------- 1 | package Collections; 2 | //Generic class 3 | class anyPair{ 4 | F first; 5 | S second; 6 | //constructor; initialize the data members during the creation of object 7 | anyPair(F first, S second){ 8 | this.first=first; 9 | this.second=second; 10 | } 11 | public F getFirst() { 12 | return first; 13 | } 14 | public S getSecond() { 15 | return second; 16 | } 17 | } 18 | //testGeneric class 19 | public class testGenericClass{ 20 | //An enumeration (enum for short) in Java is a special data type which contains a set of predefined constants. 21 | enum Month{ 22 | JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEPT,OCT,NOV,DEC; 23 | } 24 | public static void main(String[] args) { 25 | //creating object of generic class 26 | anyPair quaidDay=new anyPair(Month.DEC, 25); 27 | System.out.println(quaidDay.getFirst()+" "+quaidDay.getSecond()); 28 | } 29 | } -------------------------------------------------------------------------------- /stack.java: -------------------------------------------------------------------------------- 1 | package Postfix_eval; 2 | 3 | public class stack { 4 | //properties 5 | //as an array 6 | int[] expression; //declared array 7 | int top;//peek 8 | 9 | //constructor 10 | stack(int size){ 11 | expression=new int[size];//allocating memory -> new -> size 12 | top=-1; 13 | } 14 | //method#01 -> push 15 | void push(int c) { 16 | if(top==-1) { 17 | top++;//0 //index of given array 18 | expression[top]=c; 19 | System.out.printf("push(%d)\n",c); 20 | } 21 | else { 22 | //overflow condition 23 | if(top>=expression.length) { 24 | System.out.println("Overflow!"); 25 | } 26 | else { 27 | top++; 28 | expression[top]=c; 29 | System.out.printf("push(%d)\n",c); 30 | } 31 | } 32 | 33 | } 34 | int pop() { 35 | //underflow condition 36 | if(top<=-1) { 37 | System.out.println("Underflow!"); 38 | return -1; 39 | } 40 | 41 | else { 42 | int temp=top; 43 | top--; 44 | return expression[temp]; 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /Main_Postfix_Eval.java: -------------------------------------------------------------------------------- 1 | package Postfix_eval; 2 | import java.util.*; 3 | public class Main_Postfix_Eval { 4 | 5 | public static int Evaluate_postfix(String expression) { 6 | System.out.println("Expression : "+expression); 7 | //create the object of stack class 8 | stack stack_obj=new stack(expression.length()); 9 | for(int i=0; i index number of last element(recent) 22 | //constrcutor 23 | stackArray(int size){ 24 | this.size=size; 25 | arrayStack=new int[size]; 26 | peek=-1; 27 | } 28 | //isEmpty 29 | boolean isEmpty(){ 30 | return (peek<0); 31 | } 32 | //isFull 33 | boolean isFull(){ 34 | return (size-1==peek); 35 | } 36 | //push method 37 | public void push(int data){ 38 | if(isFull()){ 39 | System.out.println("Overfull: stack is full"); 40 | } 41 | else{ 42 | arrayStack[++peek]=data; 43 | } 44 | } 45 | //peek method 46 | public int peek(){ 47 | return arrayStack[peek]; 48 | } 49 | //display 50 | public void display(){ 51 | if(isEmpty()){ 52 | System.out.println("Stack is empty"); 53 | } 54 | else{ 55 | for(int i=0; i<=peek; i++){ 56 | System.out.println(arrayStack[i]); 57 | } 58 | } 59 | } 60 | //pop method 61 | public int pop(){ 62 | int result = arrayStack[peek]; 63 | peek--; 64 | return result; 65 | } 66 | //search method -> linear search 67 | public boolean search(int key){ 68 | if(isEmpty()){ 69 | System.out.println("stack is empty"); 70 | return false; 71 | } 72 | else{ 73 | for(int i = 0 ; i <= peek ; i++){ 74 | if(arrayStack[i] == key){ 75 | return true; 76 | } 77 | } 78 | return false; 79 | } 80 | } 81 | 82 | 83 | } 84 | -------------------------------------------------------------------------------- /testBSTree.java: -------------------------------------------------------------------------------- 1 | public class testBSTree{ 2 | public static void main(String[] args) { 3 | BST obj=new BST(); 4 | //array 5 | int[] listOfNum={12,3,6,8,10,13,15}; 6 | for(int i : listOfNum){ 7 | obj.insert(i); 8 | } 9 | System.out.println("\nInorder traversing"); 10 | obj.inOrderTraverse(obj.root); 11 | System.out.println("\nPreorder traversing"); 12 | obj.preOrderTraverse(obj.root); 13 | System.out.println("\nPostorder traversing"); 14 | obj.postOrderTraverse(obj.root); 15 | } 16 | } 17 | 18 | 19 | 20 | class BST { 21 | //node class 22 | static class Node{ 23 | //properties of node class 24 | int data; 25 | Node leftNode, rightNode; 26 | //constructor 27 | Node(int data){ 28 | this.data=data; 29 | leftNode=rightNode=null; 30 | } 31 | } 32 | //binary search tree properties 33 | int size; 34 | Node root; 35 | //constructor 36 | BST(){ 37 | size=0; 38 | root=null; 39 | } 40 | //operations of BST 41 | //1- getSize 42 | public int getSize(){ 43 | return size; 44 | } 45 | //2- isEmpty 46 | public boolean isEmpty(){ 47 | return (size==0 || root==null); 48 | } 49 | //insert 50 | public void insert(int data){ 51 | addNode(root,data); 52 | } 53 | //3- insert -> another way to implement insertion 54 | public void addNode(Node node, int data){ 55 | Node newNode=new Node(data); 56 | if(isEmpty()){ 57 | root=newNode; 58 | } 59 | else{ 60 | if((int)data<(int)node.data){ 61 | if(node.leftNode!=null){ 62 | addNode(node.leftNode, data); 63 | } 64 | else{ 65 | node.leftNode=new Node(data); 66 | } 67 | } 68 | else{ 69 | if(node.rightNode!=null){ 70 | addNode(node.rightNode, data); 71 | } 72 | else{ 73 | node.rightNode=newNode; 74 | } 75 | } 76 | } 77 | size++; 78 | } 79 | //inorder traverse 80 | public void inOrderTraverse(Node node){ 81 | if(node==null) 82 | return; 83 | else{ 84 | inOrderTraverse(node.leftNode); 85 | System.out.print(" "+node.data); 86 | inOrderTraverse(node.rightNode); 87 | } 88 | } 89 | //preorder traverse 90 | public void preOrderTraverse(Node node){ 91 | if(node==null) 92 | return; 93 | else{ 94 | System.out.print(" "+node.data); 95 | preOrderTraverse(node.leftNode); 96 | preOrderTraverse(node.rightNode); 97 | } 98 | } 99 | //postorder traverse 100 | public void postOrderTraverse(Node node){ 101 | if(node==null) 102 | return; 103 | else{ 104 | postOrderTraverse(node.leftNode); 105 | postOrderTraverse(node.rightNode); 106 | System.out.print(" "+node.data); 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /stackAsLinkedList.java: -------------------------------------------------------------------------------- 1 | package stack_main; 2 | class testStack { 3 | public static void main(String[] args) { 4 | 5 | //object of stack class 6 | stackAsLinkedList s1=new stackAsLinkedList(); 7 | 8 | System.out.println(s1.pop()); 9 | 10 | // int[] array1={11,12,13,14,15}; 11 | // for(int i : array1){ 12 | // s1.push(i); 13 | // } 14 | // System.out.println("Element at peek is : "+s1.peek()); 15 | // System.out.println("Element deleted is : "+s1.pop()); 16 | // System.out.println("Element of stacks are : "); 17 | // s1.display(); 18 | // System.out.print("Does 12 exits in stack ? "); 19 | // System.out.print(s1.search(12)); 20 | 21 | 22 | } 23 | } 24 | public class stackAsLinkedList{ 25 | //node class 26 | static class stackNdoe{ 27 | //properties of node class 28 | int data; 29 | stackNdoe nextNode; 30 | //constructor of node class 31 | stackNdoe(int data){ 32 | this.data=data; 33 | nextNode=null; 34 | } 35 | } 36 | //properties of stack 37 | int size; 38 | stackNdoe peek; //head 39 | //constructor of stack class 40 | stackAsLinkedList(){ 41 | peek=null; 42 | size=0; 43 | } 44 | //isEmpty method 45 | boolean isEmpty(){ 46 | return (peek==null); 47 | } 48 | //push method -> it is like insert at first method 49 | void push(int data){ 50 | //create new node 51 | stackNdoe newNode=new stackNdoe(data); 52 | if(isEmpty()){ 53 | peek=newNode; 54 | } 55 | else{ 56 | newNode.nextNode=peek; 57 | peek=newNode; 58 | } 59 | size++; 60 | } 61 | //pop method -> it is like delete at first method 62 | int pop(){ 63 | if(isEmpty()){ 64 | System.out.println("Underflow: stack is empty"); 65 | return -1; 66 | } 67 | else{ 68 | stackNdoe tempNode=peek; 69 | peek=tempNode.nextNode; 70 | tempNode.nextNode=null; 71 | stackNdoe deletedNode=tempNode; 72 | size--; 73 | return deletedNode.data; 74 | // System.out.println(head.data+" is deleted."); 75 | } 76 | } 77 | //peek method 78 | int peek(){ 79 | return peek.data; 80 | } 81 | //search method 82 | boolean search(int data){ 83 | stackNdoe tempNode=peek; 84 | //search node if it exists return it 85 | if(isEmpty()){ 86 | System.out.println("Underflow: stack is empty"); 87 | return false; 88 | } 89 | else{ 90 | while(tempNode!=null){ 91 | if(tempNode.data==data) 92 | return true; 93 | else 94 | tempNode=tempNode.nextNode; 95 | } 96 | return false; 97 | } 98 | } 99 | //display method 100 | public void display(){ 101 | stackNdoe tempNode=peek; 102 | //for(i=1; to size) 103 | //while(tempNode!=null) 104 | while(tempNode!=null){ 105 | System.out.println(tempNode.data); 106 | tempNode=tempNode.nextNode; 107 | } 108 | } 109 | 110 | 111 | 112 | } 113 | -------------------------------------------------------------------------------- /testArray.java: -------------------------------------------------------------------------------- 1 | // package com.mycompany.app.DSA_Labs; 2 | import java.util.Scanner; 3 | class array { 4 | //creating oject of scanner class 5 | Scanner sc=new Scanner(System.in); 6 | //size 7 | int size=0; 8 | int[] arrayNum; 9 | int[] newArray; 10 | //constructor 11 | array(int[] arrayNum, int size){ 12 | this.arrayNum=arrayNum; 13 | this.size=size; 14 | } 15 | //menu 16 | int menu(){ 17 | System.out.println("----------------------"); 18 | System.out.println("1. Create"); 19 | System.out.println("2. Display"); 20 | System.out.println("3. Size/length"); 21 | System.out.println("4. Update"); 22 | System.out.println("5. Search"); 23 | System.out.println("6. Delete"); 24 | System.out.println("7. Insert"); 25 | System.out.println("8. Exit"); 26 | System.out.println("----------------------"); 27 | System.out.print("Enter your choice : "); 28 | int choice=sc.nextInt(); 29 | return choice; 30 | } 31 | //array operations 32 | //1. Create 33 | int[] Create(){ 34 | arrayNum=new int[size]; 35 | // newArray=new int[size]; 36 | //0,1,2,3,4->5 37 | for(int i=0; i11 =-99 65 | int[] Update(int[] arrayNum){ 66 | System.out.print("Enter element you want to replace : "); 67 | int pre_element=sc.nextInt(); //11 68 | System.out.print("Enter new element you want to insert : "); 69 | int new_element=sc.nextInt();//-99 70 | //search the previous element 71 | int found_index=Search2(pre_element,arrayNum); 72 | if(found_index==-1) 73 | System.out.println("Sorry! element does not exist"); 74 | else{ 75 | for(int i=0; i5 39 | for(int i=0; i11 =-99 67 | int[] Update(int[] arrayNum){ 68 | System.out.print("Enter element you want to replace : "); 69 | int pre_element=sc.nextInt(); //11 70 | System.out.print("Enter new element you want to insert : "); 71 | int new_element=sc.nextInt();//-99 72 | //search the previous element 73 | int found_index=Search2(pre_element,arrayNum); 74 | if(found_index==-1) 75 | System.out.println("Sorry! element does not exist"); 76 | else{ 77 | for(int i=0; i Students=new singlyLinkedList<>(); 5 | String[] studentsList={"StudentA","StudentB","StudentC","StudentD","StudentE"}; 6 | for(String i : studentsList){ 7 | Students.insertAtLast(i); 8 | } 9 | //Let's us display the list of students 10 | System.out.println("21SW students list"); 11 | Students.display(); 12 | Students.deleteByValue("StudentC"); 13 | System.out.println("After deleting element StudentC"); 14 | Students.display(); 15 | Students.deleteFirstNode(); 16 | System.out.println("Students list after deleting first node : "); 17 | Students.display(); 18 | Students.deleteLastNode(); 19 | System.out.println("Students list after deleting last node"); 20 | Students.display(); 21 | Students.deteleAtAnyPos(2); 22 | System.out.println("Students list after deleting element at pos : 2"); 23 | Students.display(); 24 | 25 | } 26 | } 27 | //singly linked list class 28 | public class singlyLinkedList{ 29 | //Nested node class; it is a static class 30 | static class Node{ 31 | //proeprties 32 | L data; 33 | Node nextNode; 34 | Node(L data){ 35 | this.data=data; 36 | nextNode=null; 37 | } 38 | } 39 | //linked list class properties/Data members 40 | int size; 41 | Node head, tail; 42 | //constructor; initialized the default values 43 | singlyLinkedList(){ 44 | size=0; 45 | head=null; 46 | tail=null; 47 | } 48 | public Node getTail() { 49 | Node tempNode=head; 50 | while(tempNode.nextNode!=null){ 51 | tempNode=tempNode.nextNode; 52 | } 53 | tail=tempNode; 54 | return tail; 55 | } 56 | //isEmpty method 57 | public boolean isEmpty(){ 58 | if(size==0) 59 | return true; 60 | else 61 | return false; 62 | } 63 | // Size method 64 | public int sizeOfLinkedList(){ 65 | return size; 66 | } 67 | 68 | //insertion at first 69 | public void insertAtFirst(T data){ 70 | //create new node 71 | Node newNode=new Node(data); 72 | if(isEmpty()){ 73 | head=newNode; 74 | tail=newNode; 75 | } 76 | else{ 77 | newNode.nextNode=head; 78 | head=newNode; 79 | tail=getTail(); 80 | } 81 | size++; 82 | 83 | } 84 | // insertAtLast method 85 | public void insertAtLast(T data){ 86 | Node newNode=new Node(data);//create a new node to be inserted at last 87 | //if linked list is empty than call insert at first method 88 | if(isEmpty()){ 89 | insertAtFirst(data); 90 | } 91 | else{ 92 | getTail().nextNode=newNode; 93 | size++; 94 | // System.out.println(data+" is inserted."); 95 | } 96 | } 97 | // insert at any position 98 | public void insertAtAnyPos(T data, int pos){ 99 | if(pos==1 || isEmpty()){ 100 | insertAtFirst(data); 101 | } 102 | else if(pos>=size+1 ){ 103 | insertAtLast(data); 104 | } 105 | else if(pos>1 && pos<=size){ 106 | Node newNode, pointerNode=head; 107 | newNode=new Node(data);//create a new node 108 | for(int i=1; i tempNode=head; 124 | head=tempNode.nextNode; 125 | tempNode.nextNode=null; 126 | tail=getTail(); 127 | size--; 128 | // System.out.println(head.data+" is deleted."); 129 | } 130 | } 131 | //delete last node 132 | public void deleteLastNode(){ 133 | if(isEmpty()){ 134 | System.out.println("Underflow condition : Linked list is empty"); 135 | } 136 | else{ 137 | Node tempNode=head; 138 | for(int i=1; i=size){ 152 | deleteLastNode(); 153 | } 154 | else if(pos>1 && pos tempNode=head; 156 | for(int i=1; i tempNode=head; 174 | int nodeNum=0; 175 | //search node if it exists return it 176 | if(isEmpty()){ 177 | System.out.println("Linked list is empty"); 178 | return nodeNum; 179 | } 180 | else{ 181 | while(tempNode!=null){ 182 | nodeNum++; 183 | if(tempNode.data==data){ 184 | break; 185 | } 186 | else{ 187 | tempNode=tempNode.nextNode; 188 | } 189 | } 190 | return nodeNum; 191 | } 192 | 193 | } 194 | //Search method 195 | Node search(T data){ 196 | Node tempNode=head; 197 | //search node if it exists return it 198 | if(isEmpty()) 199 | System.out.println("Linked list is empty"); 200 | else{ 201 | 202 | } 203 | 204 | return tempNode; 205 | } 206 | 207 | //display 208 | public void display(){ 209 | Node tempNode=head; 210 | //for(i=1; to size) 211 | //while(tempNode!=null) 212 | while(tempNode!=null){ 213 | System.out.println(tempNode.data); 214 | tempNode=tempNode.nextNode; 215 | } 216 | } 217 | } 218 | 219 | -------------------------------------------------------------------------------- /testAVLTree.java: -------------------------------------------------------------------------------- 1 | // AVL tree implementation in Java 2 | 3 | // Tree class 4 | class AVL{ 5 | 6 | // Create node 7 | static class Node { 8 | int data, height; 9 | Node leftNode, rightNode; 10 | 11 | Node(int d) { 12 | data = d; 13 | height = 1; 14 | } 15 | } 16 | Node root; 17 | int height(Node N) { 18 | if (N == null) 19 | return 0; 20 | return N.height; 21 | } 22 | //case#01 Left heavy situation or Left left situation 23 | Node rightRotate(Node parent) { 24 | Node L = parent.leftNode; 25 | Node LR = L.rightNode; 26 | L.rightNode = parent; 27 | parent.leftNode = LR; 28 | parent.height = Math.max(height(parent.leftNode), height(parent.rightNode)) + 1; 29 | L.height = Math.max(height(L.leftNode), height(L.rightNode)) + 1; 30 | return L; 31 | } 32 | //case#02 Right heavy situation or right right situation 33 | Node leftRotate(Node parent) { 34 | Node R = parent.rightNode; 35 | Node RL = R.leftNode; 36 | R.leftNode = parent; 37 | parent.rightNode = RL; 38 | parent.height = Math.max(height(parent.leftNode), height(parent.rightNode)) + 1; 39 | R.height = Math.max(height(R.leftNode), height(R.rightNode)) + 1; 40 | return R; 41 | } 42 | 43 | // Get balance factor of a node 44 | int getBalanceFactor(Node N) { 45 | if (N == null) 46 | return 0; 47 | return height(N.leftNode) - height(N.rightNode); 48 | } 49 | 50 | // Insert a node 51 | Node insertNode(Node node, int data) { 52 | // Find the position and insert the node 53 | if (node == null) 54 | return (new Node(data)); 55 | if (data < node.data) 56 | node.leftNode = insertNode(node.leftNode, data); 57 | else if (data > node.data) 58 | node.rightNode = insertNode(node.rightNode, data); 59 | else 60 | return node; 61 | 62 | // Update the balance factor of each node 63 | // And, balance the tree 64 | node.height = 1 + Math.max(height(node.leftNode), height(node.rightNode)); 65 | int balanceFactor = getBalanceFactor(node); 66 | if (balanceFactor > 1) { 67 | //Left heavy situation 68 | if (data < node.leftNode.data) { 69 | return rightRotate(node); 70 | } 71 | //LR situation 72 | else if (data > node.leftNode.data) { 73 | node.leftNode = leftRotate(node.leftNode); 74 | return rightRotate(node); 75 | } 76 | } 77 | if (balanceFactor < -1) { 78 | //right heavy situation 79 | if (data > node.rightNode.data) { 80 | return leftRotate(node); 81 | } 82 | //RL rotation 83 | else if (data < node.rightNode.data) { 84 | node.rightNode = rightRotate(node.rightNode); 85 | return leftRotate(node); 86 | } 87 | } 88 | return node; 89 | } 90 | 91 | // Node nodeWithMimumValue(Node node) { 92 | // Node current = node; 93 | // while (current.leftNode != null) 94 | // current = current.leftNode; 95 | // return current; 96 | // } 97 | 98 | // // Delete a node 99 | // Node deleteNode(Node root, int data) { 100 | 101 | // // Find the node to be deleted and remove it 102 | // if (root == null) 103 | // return root; 104 | // if (data < root.data) 105 | // root.leftNode = deleteNode(root.leftNode, data); 106 | // else if (data > root.data) 107 | // root.rightNode = deleteNode(root.rightNode, data); 108 | // else { 109 | // if ((root.leftNode == null) || (root.rightNode == null)) { 110 | // Node temp = null; 111 | // if (temp == root.leftNode) 112 | // temp = root.rightNode; 113 | // else 114 | // temp = root.leftNode; 115 | // if (temp == null) { 116 | // temp = root; 117 | // root = null; 118 | // } else 119 | // root = temp; 120 | // } else { 121 | // Node temp = nodeWithMimumValue(root.rightNode); 122 | // root.data = temp.data; 123 | // root.rightNode = deleteNode(root.rightNode, temp.data); 124 | // } 125 | // } 126 | // if (root == null) 127 | // return root; 128 | 129 | // // Update the balance factor of each node and balance the tree 130 | // root.height = Math.max(height(root.leftNode), height(root.rightNode)) + 1; 131 | // int balanceFactor = getBalanceFactor(root); 132 | // if (balanceFactor > 1) { 133 | // if (getBalanceFactor(root.leftNode) >= 0) { 134 | // return rightRotate(root); 135 | // } else { 136 | // root.leftNode = leftRotate(root.leftNode); 137 | // return rightRotate(root); 138 | // } 139 | // } 140 | // if (balanceFactor < -1) { 141 | // if (getBalanceFactor(root.rightNode) <= 0) { 142 | // return leftRotate(root); 143 | // } else { 144 | // root.rightNode = rightRotate(root.rightNode); 145 | // return leftRotate(root); 146 | // } 147 | // } 148 | // return root; 149 | // } 150 | //traversing 151 | //inorder traverse 152 | public void inOrderTraverse(Node node){ 153 | if(node==null) 154 | return; 155 | else{ 156 | inOrderTraverse(node.leftNode); 157 | System.out.print(" "+node.data); 158 | inOrderTraverse(node.rightNode); 159 | } 160 | } 161 | //preorder traverse 162 | public void preOrderTraverse(Node node){ 163 | if(node==null) 164 | return; 165 | else{ 166 | System.out.print(" "+node.data); 167 | preOrderTraverse(node.leftNode); 168 | preOrderTraverse(node.rightNode); 169 | } 170 | } 171 | //postorder traverse 172 | public void postOrderTraverse(Node node){ 173 | if(node==null) 174 | return; 175 | else{ 176 | postOrderTraverse(node.leftNode); 177 | postOrderTraverse(node.rightNode); 178 | System.out.print(" "+node.data); 179 | } 180 | } 181 | public void display(){ 182 | System.out.println("\nInorder"); 183 | inOrderTraverse(root); 184 | System.out.println("\nPreoder"); 185 | preOrderTraverse(root); 186 | System.out.println("\nPostorder"); 187 | postOrderTraverse(root); 188 | } 189 | // Print the tree 190 | // public void printTree(Node currPtr, String indent, boolean last) { 191 | // if (currPtr != null) { 192 | // System.out.print(indent); 193 | // if (last) { 194 | // System.out.print("R----"); 195 | // indent += " "; 196 | // } else { 197 | // System.out.print("L----"); 198 | // indent += "| "; 199 | // } 200 | // System.out.println(currPtr.data); 201 | // printTree(currPtr.leftNode, indent, false); 202 | // printTree(currPtr.rightNode, indent, true); 203 | // } 204 | // } 205 | 206 | } 207 | public class testAVLTree{ 208 | // Driver code 209 | public static void main(String[] args) { 210 | AVL tree = new AVL(); 211 | int[] listNum={33,13,53,9,21,61,8,11}; 212 | for(int i : listNum){ 213 | tree.root = tree.insertNode(tree.root,i); 214 | } 215 | // tree.printTree(tree.root, "", true); 216 | tree.display(); 217 | } 218 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Data Structures and Algorithms in Java 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 |
TopicArticleCodeRecorded Video
Introduction to Java linklinklink
Generic classes linklinklink
Creating an array linklinklink
Iterating over an array linklinklink
Updating elements in an array linklinklink
Removing elements from an array linklinklink
Adding elements to an array linklinklink
Searching for an element in an array linklinklink
Introduction to Singly Linked List linklinklink
Insertion in Singly Linked List linklinklink
Deletion in Singly Linked List linklinklink
Stack using array linklinklink
Stack using linked list linklinklink
Postfix Expression using Stack(as an array) linklinklink
Evaluating Postfix Expression using Stack(as an array) linklinklink
Binary Search Tree linklinklink
AVL Tree linklinklink
134 | 135 | 136 | 137 | 138 | 139 | 140 | --------------------------------------------------------------------------------