Preview

Compare Cpu Scheduling of Linux and Unix.

Good Essays
Open Document
Open Document
2419 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Compare Cpu Scheduling of Linux and Unix.
Binary Search Trees basic implementations randomized BSTs deletion in BSTs

References: Algorithms in Java, Chapter 12 Intro to Programming, Section 4.4 http://www.cs.princeton.edu/introalgsds/43bst 1

Elementary implementations: summary

implementation

worst case search insert N N N N

average case search N/2 lg N N/2 N/2 insert N/2 N/2 N N/2

ordered iteration? no yes no yes

operations on keys equals() compareTo() equals() compareTo()

unordered array ordered array unordered list ordered list

N lg N N N

Challenge: Efficient implementations of get() and put() and ordered iteration.
2

basic implementations randomized BSTs deletion in BSTs

3

Binary Search Trees (BSTs) Def. A BINARY SEARCH TREE is a binary tree in symmetric order. it A binary tree is either: empty a key-value pair and two binary trees [neither of which contain that key]

• •

best of

the

was times

equal keys ruled out to facilitate associative array implementations

Symmetric order means that: every node has a key every node’s key is larger than all keys in its left subtree smaller than all keys in its right subtree

• •

node

x subtrees smaller

larger
4

BST representation A BST is a reference to a Node. A Node is comprised of four fields: A key and a value. A reference to the left and right subtree.

• •

smaller keys

larger keys

root private class Node { Key key; Value val; Node left, right; }
Key and Value are generic types; Key is Comparable

it

2

best

1

was

2

the

1

of

1

times

1
5

BST implementation (skeleton)

public class BST implements Iterable { instance variable private Node root; private class Node { Key key; Value val; Node left, right; Node(Key key, Value val) { this.key = key; this.val = val; } } inner class

public void put(Key key, Value val) // see next slides public Val get(Key key) // see next slides }
6

BST implementation (search)

public Value

You May Also Find These Documents Helpful

  • Good Essays

    Nt1420 Unit 6

    • 1145 Words
    • 5 Pages

    class Link { public int iData; // data item public double dData; // data item public Link next; // next link in list // ------------------------------------------------------------public Link(int id, double dd) // constructor { iData = id; // initialize data dData = dd; // ('next' is automatically } // set to null) // ------------------------------------------------------------public void displayLink() // display ourself { System.out.print("{" + iData + ", " + dData + "} "); } } // end class Link //////////////////////////////////////////////////////////////// class LinkList { private Link first; // ref to first link on list // ------------------------------------------------------------public LinkList() // constructor { first = null; // no links on list yet } // ------------------------------------------------------------public boolean isEmpty() // true if list is empty { return…

    • 1145 Words
    • 5 Pages
    Good Essays
  • Good Essays

    Nt1310 Unit 1 Test Paper

    • 381 Words
    • 2 Pages

    3. Create a binary search function that tells whether a given value exists in the tree or not.…

    • 381 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    ITN Final Chp 7 Through 12

    • 7250 Words
    • 75 Pages

    A hierarchical tree of domains within one organization that is linked to other trees in the organization is called a ___________.…

    • 7250 Words
    • 75 Pages
    Satisfactory Essays
  • Good Essays

    Cse 373 Final Note

    • 955 Words
    • 4 Pages

    For every non-root node x, the value in the parent of x is less than or equal to the value in x.…

    • 955 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Unit 7 Quiz 5

    • 507 Words
    • 9 Pages

    The ______________ is a database of all object names in the forest and aids in locating objects…

    • 507 Words
    • 9 Pages
    Satisfactory Essays
  • Good Essays

    | The default shell is bash. The shell allows users to type commands and have the output displayed on the screen.…

    • 489 Words
    • 2 Pages
    Good Essays
  • Good Essays

    | |system. The access controls are |required. There is a requisite |possible threats and fixes. |…

    • 1522 Words
    • 7 Pages
    Good Essays
  • Good Essays

    Info1105

    • 951 Words
    • 4 Pages

    Now if we traverse the list from head to tail, we always get a sorted list.…

    • 951 Words
    • 4 Pages
    Good Essays
  • Better Essays

    2. Radeon UVD support – deals with hardware decoding of H.264 and VC-1 video codes…

    • 1499 Words
    • 6 Pages
    Better Essays
  • Powerful Essays

    Cen 254 Data Structure

    • 924 Words
    • 4 Pages

    keys 30, 40, 24, 58, 48, 26, 11, 13 (in this order). Draw the tree after each…

    • 924 Words
    • 4 Pages
    Powerful Essays
  • Good Essays

    Deciding which data structure to then write it in java was challenging cause you have to make sure that the steps are in the right sequence for the program to work.…

    • 605 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Bachman Notation also known as data structure diagram is used to design the data with a network or relational logical model. It divides the data from model. This is how the data is stored in the system.…

    • 336 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Question 1: There is a binary tree of size N. All nodes are numbered between 1-N(inclusive). There is a N*N integer matrix Arr[N][N], all elements are initialized to zero. So for all the nodes A and B, put Arr[A][B] = 1 if A is an ancestor of B (NOT just the immediate ancestor).…

    • 359 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Parallel Arrays

    • 427 Words
    • 2 Pages

    Key in saving wasted memory. The nodes of a linked data structure can also be moved individually to different locations without affecting the logical connections between them, unlike arrays. With due care, a process can add or delete nodes to one part of a data structure even while other processes are working on other parts. On the other hand, access to any particular node in a linked data structure requires following a chain of references that stored in it. If the structure has n nodes, and each node contains at most b links, there will be some nodes that cannot be reached in less than log b n steps. For many structures, some nodes may require worst case up to n -1 steps.…

    • 427 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    * Basic hierarchical structure, and is most widely used organisational structure in the world today…

    • 1458 Words
    • 6 Pages
    Satisfactory Essays