SlideShare a Scribd company logo
1 of 6
Download to read offline
// TO DO: add your implementation and JavaDocs.
public class ThreeTenKTree {
//K-ary tree with an array as internal storage.
//All nodes are stored in the array following level-order top-down
//and left-to-right within one level.
//Root at index 0.
//underlying array for k-ary tree storage
// -- you MUST use this for credit! Do NOT change the name or type
private E[] storage;
//hash table to help remember the index of each stored value
private ThreeTenHashTable indexMap;
//branching factor
private int branchK;
// ADD MORE PRIVATE MEMBERS HERE IF NEEDED!
@SuppressWarnings("unchecked")
public ThreeTenKTree(int length, int k) {
//initialize tree storage as an array of given length
// and branching factor as k.
//May assyme the given length ensures the storage for a perfect tree.
//For example, if k=2, length will be of 1, 3, 7, 15, 29, etc.
//If k=3, length will be of length 1, 4, 13, etc.
//May also assume k>=2.
//Also initialize the hash table with ThreeTenHashTable.defaultTableLength.
}
public int getBranch(){
//report branching factor
//O(1)
return -1; //default return, change or remove as needed
}
public int size() {
//report number of non-null nodes in tree
//O(1)
return -1; //default return, change or remove as needed
}
public int capacity(){
//report the length of storage
//this should be the no. of nodes of a perfect tree of the current height
//O(1)
return -1; //default return, change or remove as needed
}
public int height() {
//report the tree height
//O(1)
return -1; //default return, change or remove as needed
}
@SuppressWarnings("unchecked")
public boolean set(int index, E value) {
// Set value at index in tree storage.
// If value is null, this method attempts to remove a (leaf) node.
// - If index is not valid or the given index does not have a node,
// no change to tree and return false;
// - If node at given index has any child, do not remove and return false;
// - Otherwise, remove the node and return true.
// If value is not null, this method attempts to add/replace a node.
// - If value is already in tree (any index), no change and return false;
// - If value is new and index denotes a valid node of current tree, set value
// at this node and return true;
// - You may need to grow the tree storage (i.e. add a level) for this node
// - If adding this node would make the tree invalid, no change and return false.
// See examples in main() below for different cases.
// Remember to update the hash table if tree is updated.
return false; //default return, change or remove as needed
}
public E get(int index) {
//Return value at node index.
// - return null for invalid index or index with no node in tree
// O(1)
return null; //default return, change or remove as needed
}
public String toStringLevelOrder() {
//Return a string of all nodes (excluding null nodes) in tree storage:
// - include all levels from top down
// - all nodes are printed with a single space separated
// - return an empty string if tree is null
// Note: use StringBuilder instead of String concatenation
// Example:
// binary tree: A
// / 
// B C
// / /
// D E
//
// toStringLevelOrder() should return "A B C D E"
return ""; //default return, change or remove as needed
}
@Override
public String toString() {
//Return a string of all nodes (including null nodes) in tree storage:
// - include all levels from top down
// - each level is printed on its own line
// - each node in the level is printed with a single space separated
// - null nodes included in string
// - return an empty string if tree is null
// Note: use StringBuilder instead of String concatenation
// Example:
// binary tree: A
// / 
// B C
// / /
// D E
//
// toString() should return "AnB CnD null E null"
return ""; //default return, change or remove as needed
}
public String getAncestors(E value){
//Find the node of the given value and return the ancestors of the node in a string:
// - if value not present, return null
// - return string should include all ancestors including the node itself
// - ancestors should start from root and separated by "-->"
// O(height) assuming hash table search is O(1)
return ""; //default return, change or remove as needed
}
public String getChildren(E value){
//Find the node of the given value and return the children of the node in a string:
// - if value not present, return null
// - if the node is a leaf, return an empty string
// - return string should include all children, from left to right,
// and separated by a single space
// O(K) where K is the branch factor assuming hash table search is O(1)
return ""; //default return, change or remove as needed
}
public boolean has(E value){
//Determine if value is in tree or not
// - return true if a tree node has value; false otherwise
// - null is not a valid value in tree
// O(1) assuming hash table search is O(1)
return false; //default return, change or remove as needed
}
public boolean isLeaf(E value){
//Determine if value is in a leaf node of tree or not
// - return true if a leaf node has value; false otherwise
// O(K) where K is the branching factor assuming hash table search is O(1)
return false; //default return, change or remove as needed
}
public boolean remove(E value){
//Remove value from tree if value is in a leaf node
// - if value not present, return false
// - if value present but not in a leaf node, do not remove and return false
// - if value is in a leaf node, remove node from tree and return true
return false; //default return, change or remove as needed
}
public static FcnsTreeNode createFcnsTree(ThreeTenKTree ktree){
//construct the corresponding first-child-next-sibling tree
//for this k-ary tree and return the root node of the FCNS tree.
// Consider helper methods; consider a recursive approach.
// O(N) where N is the size of the current K-ary tree.
return null; //default return, change or remove as needed
}

More Related Content

Similar to TO DO add your implementation and JavaDocs.public class ThreeT.pdf

Program to insert in a sorted list #includestdio.h#include.pdf
 Program to insert in a sorted list #includestdio.h#include.pdf Program to insert in a sorted list #includestdio.h#include.pdf
Program to insert in a sorted list #includestdio.h#include.pdf
sudhirchourasia86
ย 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
JamesPXNNewmanp
ย 
Templated Binary Tree implementing function help I need to im.pdf
Templated Binary Tree implementing function help I need to im.pdfTemplated Binary Tree implementing function help I need to im.pdf
Templated Binary Tree implementing function help I need to im.pdf
manjan6
ย 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
kingsandqueens3
ย 
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdfObjective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
sivakumar19831
ย 
This is problem is same problem which i submitted on 22017, I just.pdf
This is problem is same problem which i submitted on 22017, I just.pdfThis is problem is same problem which i submitted on 22017, I just.pdf
This is problem is same problem which i submitted on 22017, I just.pdf
fcaindore
ย 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdf
contact41
ย 
Use the singly linked list class introduced in the lab to implement .pdf
Use the singly linked list class introduced in the lab to implement .pdfUse the singly linked list class introduced in the lab to implement .pdf
Use the singly linked list class introduced in the lab to implement .pdf
sales87
ย 
Given below is the completed implementation of MyLinkedList class. O.pdf
Given below is the completed implementation of MyLinkedList class. O.pdfGiven below is the completed implementation of MyLinkedList class. O.pdf
Given below is the completed implementation of MyLinkedList class. O.pdf
info430661
ย 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdf
sales98
ย 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf
afgt2012
ย 
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf
petercoiffeur18
ย 
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdfNeed Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Edwardw5nSlaterl
ย 
C++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docxC++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docx
MatthPYNashd
ย 
in Java (ignore the last line thats hidden) Create a doubly linked l.pdf
in Java (ignore the last line thats hidden) Create a doubly linked l.pdfin Java (ignore the last line thats hidden) Create a doubly linked l.pdf
in Java (ignore the last line thats hidden) Create a doubly linked l.pdf
sauravmanwanicp
ย 
import java.util.Iterator; import java.util.NoSuchElementException; .pdf
  import java.util.Iterator; import java.util.NoSuchElementException; .pdf  import java.util.Iterator; import java.util.NoSuchElementException; .pdf
import java.util.Iterator; import java.util.NoSuchElementException; .pdf
deepakangel
ย 

Similar to TO DO add your implementation and JavaDocs.public class ThreeT.pdf (20)

Program to insert in a sorted list #includestdio.h#include.pdf
 Program to insert in a sorted list #includestdio.h#include.pdf Program to insert in a sorted list #includestdio.h#include.pdf
Program to insert in a sorted list #includestdio.h#include.pdf
ย 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
ย 
Templated Binary Tree implementing function help I need to im.pdf
Templated Binary Tree implementing function help I need to im.pdfTemplated Binary Tree implementing function help I need to im.pdf
Templated Binary Tree implementing function help I need to im.pdf
ย 
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdfProblem- Describe an algorithm for concatenating two singly linked lis.pdf
Problem- Describe an algorithm for concatenating two singly linked lis.pdf
ย 
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdfObjective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
Objective Binary Search Tree traversal (2 points)Use traversal.pp.pdf
ย 
This is problem is same problem which i submitted on 22017, I just.pdf
This is problem is same problem which i submitted on 22017, I just.pdfThis is problem is same problem which i submitted on 22017, I just.pdf
This is problem is same problem which i submitted on 22017, I just.pdf
ย 
CppQuickRef.pdf
CppQuickRef.pdfCppQuickRef.pdf
CppQuickRef.pdf
ย 
C++ QUICK REFERENCE.pdf
C++ QUICK REFERENCE.pdfC++ QUICK REFERENCE.pdf
C++ QUICK REFERENCE.pdf
ย 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdf
ย 
Use the singly linked list class introduced in the lab to implement .pdf
Use the singly linked list class introduced in the lab to implement .pdfUse the singly linked list class introduced in the lab to implement .pdf
Use the singly linked list class introduced in the lab to implement .pdf
ย 
Given below is the completed implementation of MyLinkedList class. O.pdf
Given below is the completed implementation of MyLinkedList class. O.pdfGiven below is the completed implementation of MyLinkedList class. O.pdf
Given below is the completed implementation of MyLinkedList class. O.pdf
ย 
Describe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdfDescribe an algorithm for concatenating two singly linked lists L and.pdf
Describe an algorithm for concatenating two singly linked lists L and.pdf
ย 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdf
ย 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf
ย 
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf
ย 
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdfNeed Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
ย 
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdfImplement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
ย 
C++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docxC++ please put everthing after you answer it- thanks Complete the stub.docx
C++ please put everthing after you answer it- thanks Complete the stub.docx
ย 
in Java (ignore the last line thats hidden) Create a doubly linked l.pdf
in Java (ignore the last line thats hidden) Create a doubly linked l.pdfin Java (ignore the last line thats hidden) Create a doubly linked l.pdf
in Java (ignore the last line thats hidden) Create a doubly linked l.pdf
ย 
import java.util.Iterator; import java.util.NoSuchElementException; .pdf
  import java.util.Iterator; import java.util.NoSuchElementException; .pdf  import java.util.Iterator; import java.util.NoSuchElementException; .pdf
import java.util.Iterator; import java.util.NoSuchElementException; .pdf
ย 

More from jkcs20004

This is a study case in all the photosthe SIPOC diagram bel.pdf
 This is a study case in all the photosthe SIPOC diagram bel.pdf This is a study case in all the photosthe SIPOC diagram bel.pdf
This is a study case in all the photosthe SIPOC diagram bel.pdf
jkcs20004
ย 
To which of the following facts is the anatomy of birds not s.pdf
 To which of the following facts is the anatomy of birds not s.pdf To which of the following facts is the anatomy of birds not s.pdf
To which of the following facts is the anatomy of birds not s.pdf
jkcs20004
ย 
Theres no doubt that today we face many environmental problems poll.pdf
 Theres no doubt that today we face many environmental problems poll.pdf Theres no doubt that today we face many environmental problems poll.pdf
Theres no doubt that today we face many environmental problems poll.pdf
jkcs20004
ย 

More from jkcs20004 (20)

Thi wiecis only eartaint pat a The seial wadar production emet=1 EEtr.pdf
 Thi wiecis only eartaint pat a The seial wadar production emet=1 EEtr.pdf Thi wiecis only eartaint pat a The seial wadar production emet=1 EEtr.pdf
Thi wiecis only eartaint pat a The seial wadar production emet=1 EEtr.pdf
ย 
This lab deals with the layers of the Earth, Endogenic and Exogenic s.pdf
 This lab deals with the layers of the Earth, Endogenic and Exogenic s.pdf This lab deals with the layers of the Earth, Endogenic and Exogenic s.pdf
This lab deals with the layers of the Earth, Endogenic and Exogenic s.pdf
ย 
This continuous probability distribution always has a =0 and =1 T.pdf
 This continuous probability distribution always has a =0 and =1 T.pdf This continuous probability distribution always has a =0 and =1 T.pdf
This continuous probability distribution always has a =0 and =1 T.pdf
ย 
There is mountain with a popular hiking trail. At one point on the tr.pdf
 There is mountain with a popular hiking trail. At one point on the tr.pdf There is mountain with a popular hiking trail. At one point on the tr.pdf
There is mountain with a popular hiking trail. At one point on the tr.pdf
ย 
There is a bacteria called C. difficile that is found in the large in.pdf
 There is a bacteria called C. difficile that is found in the large in.pdf There is a bacteria called C. difficile that is found in the large in.pdf
There is a bacteria called C. difficile that is found in the large in.pdf
ย 
There is discussion among the board about our dividend strategy, alth.pdf
 There is discussion among the board about our dividend strategy, alth.pdf There is discussion among the board about our dividend strategy, alth.pdf
There is discussion among the board about our dividend strategy, alth.pdf
ย 
These transactions took place for Blossom Co. 2024 May 1 Recelved a $.pdf
 These transactions took place for Blossom Co. 2024 May 1 Recelved a $.pdf These transactions took place for Blossom Co. 2024 May 1 Recelved a $.pdf
These transactions took place for Blossom Co. 2024 May 1 Recelved a $.pdf
ย 
This is a study case in all the photosthe SIPOC diagram bel.pdf
 This is a study case in all the photosthe SIPOC diagram bel.pdf This is a study case in all the photosthe SIPOC diagram bel.pdf
This is a study case in all the photosthe SIPOC diagram bel.pdf
ย 
There are ten colour cards in a perfectly covered box, each in a diff.pdf
 There are ten colour cards in a perfectly covered box, each in a diff.pdf There are ten colour cards in a perfectly covered box, each in a diff.pdf
There are ten colour cards in a perfectly covered box, each in a diff.pdf
ย 
This is a pedigree for a family with a history of alkaptonuria, a rar.pdf
 This is a pedigree for a family with a history of alkaptonuria, a rar.pdf This is a pedigree for a family with a history of alkaptonuria, a rar.pdf
This is a pedigree for a family with a history of alkaptonuria, a rar.pdf
ย 
Topic - research and choose a company that has committed to BI. Descr.pdf
 Topic - research and choose a company that has committed to BI. Descr.pdf Topic - research and choose a company that has committed to BI. Descr.pdf
Topic - research and choose a company that has committed to BI. Descr.pdf
ย 
Tom collected an informal gender based data sample at his university..pdf
 Tom collected an informal gender based data sample at his university..pdf Tom collected an informal gender based data sample at his university..pdf
Tom collected an informal gender based data sample at his university..pdf
ย 
To which of the following facts is the anatomy of birds not s.pdf
 To which of the following facts is the anatomy of birds not s.pdf To which of the following facts is the anatomy of birds not s.pdf
To which of the following facts is the anatomy of birds not s.pdf
ย 
Tobac Company reported an operating loss of $132,000 for financial re.pdf
 Tobac Company reported an operating loss of $132,000 for financial re.pdf Tobac Company reported an operating loss of $132,000 for financial re.pdf
Tobac Company reported an operating loss of $132,000 for financial re.pdf
ย 
to orpere 8- Ourrot Liablities and the Ziquidity Anabyis subtopic f.pdf
 to orpere 8- Ourrot Liablities and the Ziquidity Anabyis subtopic f.pdf to orpere 8- Ourrot Liablities and the Ziquidity Anabyis subtopic f.pdf
to orpere 8- Ourrot Liablities and the Ziquidity Anabyis subtopic f.pdf
ย 
to sate that the previlenon of salmonela in the regions water difers.pdf
 to sate that the previlenon of salmonela in the regions water difers.pdf to sate that the previlenon of salmonela in the regions water difers.pdf
to sate that the previlenon of salmonela in the regions water difers.pdf
ย 
Theres no doubt that today we face many environmental problems poll.pdf
 Theres no doubt that today we face many environmental problems poll.pdf Theres no doubt that today we face many environmental problems poll.pdf
Theres no doubt that today we face many environmental problems poll.pdf
ย 
Therefore, converted to a z interval, we wish to find P(z0.61). Note .pdf
 Therefore, converted to a z interval, we wish to find P(z0.61). Note .pdf Therefore, converted to a z interval, we wish to find P(z0.61). Note .pdf
Therefore, converted to a z interval, we wish to find P(z0.61). Note .pdf
ย 
To map a newly discovered mutation that is proposed to contribute to .pdf
 To map a newly discovered mutation that is proposed to contribute to .pdf To map a newly discovered mutation that is proposed to contribute to .pdf
To map a newly discovered mutation that is proposed to contribute to .pdf
ย 
There is a relationship between tables T1 and T2, and the columns inv.pdf
 There is a relationship between tables T1 and T2, and the columns inv.pdf There is a relationship between tables T1 and T2, and the columns inv.pdf
There is a relationship between tables T1 and T2, and the columns inv.pdf
ย 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
ย 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
akanksha16arora
ย 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
ย 

Recently uploaded (20)

Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
ย 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
ย 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
ย 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
ย 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
ย 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
ย 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
ย 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
ย 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
ย 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
ย 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
ย 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
ย 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
ย 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
ย 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
ย 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
ย 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
ย 
Introduction to TechSoupโ€™s Digital Marketing Services and Use Cases
Introduction to TechSoupโ€™s Digital Marketing  Services and Use CasesIntroduction to TechSoupโ€™s Digital Marketing  Services and Use Cases
Introduction to TechSoupโ€™s Digital Marketing Services and Use Cases
ย 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
ย 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
ย 

TO DO add your implementation and JavaDocs.public class ThreeT.pdf

  • 1. // TO DO: add your implementation and JavaDocs. public class ThreeTenKTree { //K-ary tree with an array as internal storage. //All nodes are stored in the array following level-order top-down //and left-to-right within one level. //Root at index 0. //underlying array for k-ary tree storage // -- you MUST use this for credit! Do NOT change the name or type private E[] storage; //hash table to help remember the index of each stored value private ThreeTenHashTable indexMap; //branching factor private int branchK; // ADD MORE PRIVATE MEMBERS HERE IF NEEDED! @SuppressWarnings("unchecked") public ThreeTenKTree(int length, int k) { //initialize tree storage as an array of given length // and branching factor as k. //May assyme the given length ensures the storage for a perfect tree. //For example, if k=2, length will be of 1, 3, 7, 15, 29, etc. //If k=3, length will be of length 1, 4, 13, etc. //May also assume k>=2. //Also initialize the hash table with ThreeTenHashTable.defaultTableLength. } public int getBranch(){ //report branching factor //O(1) return -1; //default return, change or remove as needed }
  • 2. public int size() { //report number of non-null nodes in tree //O(1) return -1; //default return, change or remove as needed } public int capacity(){ //report the length of storage //this should be the no. of nodes of a perfect tree of the current height //O(1) return -1; //default return, change or remove as needed } public int height() { //report the tree height //O(1) return -1; //default return, change or remove as needed } @SuppressWarnings("unchecked") public boolean set(int index, E value) { // Set value at index in tree storage. // If value is null, this method attempts to remove a (leaf) node. // - If index is not valid or the given index does not have a node, // no change to tree and return false; // - If node at given index has any child, do not remove and return false; // - Otherwise, remove the node and return true. // If value is not null, this method attempts to add/replace a node. // - If value is already in tree (any index), no change and return false; // - If value is new and index denotes a valid node of current tree, set value // at this node and return true;
  • 3. // - You may need to grow the tree storage (i.e. add a level) for this node // - If adding this node would make the tree invalid, no change and return false. // See examples in main() below for different cases. // Remember to update the hash table if tree is updated. return false; //default return, change or remove as needed } public E get(int index) { //Return value at node index. // - return null for invalid index or index with no node in tree // O(1) return null; //default return, change or remove as needed } public String toStringLevelOrder() { //Return a string of all nodes (excluding null nodes) in tree storage: // - include all levels from top down // - all nodes are printed with a single space separated // - return an empty string if tree is null // Note: use StringBuilder instead of String concatenation // Example: // binary tree: A // / // B C // / / // D E // // toStringLevelOrder() should return "A B C D E" return ""; //default return, change or remove as needed }
  • 4. @Override public String toString() { //Return a string of all nodes (including null nodes) in tree storage: // - include all levels from top down // - each level is printed on its own line // - each node in the level is printed with a single space separated // - null nodes included in string // - return an empty string if tree is null // Note: use StringBuilder instead of String concatenation // Example: // binary tree: A // / // B C // / / // D E // // toString() should return "AnB CnD null E null" return ""; //default return, change or remove as needed } public String getAncestors(E value){ //Find the node of the given value and return the ancestors of the node in a string: // - if value not present, return null // - return string should include all ancestors including the node itself // - ancestors should start from root and separated by "-->" // O(height) assuming hash table search is O(1) return ""; //default return, change or remove as needed }
  • 5. public String getChildren(E value){ //Find the node of the given value and return the children of the node in a string: // - if value not present, return null // - if the node is a leaf, return an empty string // - return string should include all children, from left to right, // and separated by a single space // O(K) where K is the branch factor assuming hash table search is O(1) return ""; //default return, change or remove as needed } public boolean has(E value){ //Determine if value is in tree or not // - return true if a tree node has value; false otherwise // - null is not a valid value in tree // O(1) assuming hash table search is O(1) return false; //default return, change or remove as needed } public boolean isLeaf(E value){ //Determine if value is in a leaf node of tree or not // - return true if a leaf node has value; false otherwise // O(K) where K is the branching factor assuming hash table search is O(1) return false; //default return, change or remove as needed } public boolean remove(E value){ //Remove value from tree if value is in a leaf node // - if value not present, return false
  • 6. // - if value present but not in a leaf node, do not remove and return false // - if value is in a leaf node, remove node from tree and return true return false; //default return, change or remove as needed } public static FcnsTreeNode createFcnsTree(ThreeTenKTree ktree){ //construct the corresponding first-child-next-sibling tree //for this k-ary tree and return the root node of the FCNS tree. // Consider helper methods; consider a recursive approach. // O(N) where N is the size of the current K-ary tree. return null; //default return, change or remove as needed }