I am just looking for some qucick useful notes on these topics: There is so much
ID: 3836787 • Letter: I
Question
I am just looking for some qucick useful notes on these topics:
There is so much information I can use but can someone fill it in with what you think I should take
• Recursion (study slides set on Recursive Lecture closely)
o Recursive Thinking: understand recursive definitions, be able to exercise recursive
thinking and understand and recognize infinite recursions. Review binary search
algorithm and quicksort.
o Recursive Programming: understand and use recursive programming, be able to
write recursive methods as well as tracing them.
• Collections
o Understand the concept of Linked List, Stacks, and Queues Abstract Data Types
(ADT). Know how to apply and use their operations (see Palindrome lab).
• Analysis of algorithms
o Understand Big O notation. Know how to analyze simple programs using primitive
operations.
o Sorting: understand and demonstrate the usage of Bubble, Selection Sort,
Quicksort, and Insertion Sort. Analyze the algorithms under worst case scenarios.
o Searching: understand and demonstrate the use of Linear Search and Binary Search.
Explanation / Answer
import java.util.Scanner;
/* category AVLNode */
category AVLNode
builder */
public AVLNode()
/* creator */
public AVLNode(int n)
}
/* category AVLTree */
category AVLTree
personal AVLNode root;
/* creator */
public AVLTree()
/* perform to envision if tree is empty */
public Boolean isEmpty()
come back root == null;
}
/* build the tree logically empty */
public void makeEmpty()
/* perform to insert information */
public void insert(int data)
/* perform to induce height of node */
non-public int height(AVLNode t )
come back t == null ? -1 : t.height;
}
/* perform to GHB of left/right node */
non-public int max(int lhs, int rhs)
come back lhs > rhs ? lhs : rhs;
}
/* perform to insert information recursively */
non-public AVLNode insert(int x, AVLNode t)
a pair of )
if( x < t.left.data )
t = rotateWithLeftChild( t );
else
t = doubleWithLeftChild( t );
}
else if( x > t.data )
two )
if( x > t.right.data)
t = rotateWithRightChild( t );
else
t = doubleWithRightChild( t );
}
else
; // Duplicate; do nothing
t.height = max( height( t.left ), height( t.right ) ) + 1;
return t;
}
/* Rotate binary tree node with left kid */
non-public AVLNode rotateWithLeftChild(AVLNode k2)
Dapsang.left;
k2.left = k1.right;
k1.right = k2;
k2.height = max( height( Mount Godwin Austen.left ), height( k2.right ) ) + 1;
k1.height = max( height( k1.left ), k2.height ) + 1;
return k1;
}
/* Rotate binary tree node with right kid */
non-public AVLNode rotateWithRightChild(AVLNode k1)
{
AVLNode Mount Godwin Austen = k1.right;
k1.right = k2.left;
k2.left = k1;
k1.height = max( height( k1.left ), height( k1.right ) ) + 1;
k2.height = max( height( Mount Godwin Austen.right ), k1.height ) + 1;
return k2;
}
/**
* Double rotate binary tree node: 1st left kid
* with its right kid; then node k3 with new left child */
non-public AVLNode doubleWithLeftChild(AVLNode k3)
come back rotateWithLeftChild( k3 );
}
/**
* Double rotate binary tree node: 1st right kid
* with its left kid; then node k1 with new right child */
non-public AVLNode doubleWithRightChild(AVLNode k1)
come rotateWithRightChild( k1 );
}
/* Functions to count range of nodes */
public int countNodes()
come back countNodes(root);
}
non-public int countNodes(AVLNode r)
}
/* Functions to look for a part */
public Boolean search(int val)
come back search(root, val);
}
non-public Boolean search(AVLNode r, int val)
{
Boolean found = false;
whereas ((r != null) && !found)
found = search(r, val);
}
come found;
}
/* perform for inorder traversal */
public void inorder()
non-public void inorder(AVLNode r)
non-public void preorder(AVLNode r)
non-public void postorder(AVLNode r)
making object of AVLTree */
AVLTree avlt = new AVLTree();
System.out.println("AVLTree Tree Test ");
char ch;
/* Perform tree operations */
do
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.