CPSC 331 Information Structutes- Design a Linear Time Algorithm

$20 Bonus + 25% OFF

Securing Higher Grades Costing Your Pocket?
Book Your Assignment at The Lowest Price
Now!

Students Who Viewed This Also Studied

CPSC 331 Information Structutes

Task

1. [20%] Implement a variant of the stack data structure, so that on top of the three primitives, PUSH, POP, and TOP, there is now a new primitive, MAX.

• MAX(S): returns the maximum key currently in the stack S.

It is assumed that the data type of the keys supports comparisons (i.e., “≤”). Other than that, we do not know anything about the data type of the keys. Your solution is evaluated by how competitive its performance (running time) is.

2. [20%] Design a linear-time algorithm that converts a sorted, doubly linked list into a balanced binary search tree. The only thing we know about the data type of the keys is that they are comparable (i.e., “≤”). You may further assume that the keys in the linked list are distinct. It is okay for the algorithm to be destructive (meaning it modifies the original linked list or even distroys it). It is also okay to use additional space (so long as the amount is reasonable).

3. [20%] Exercise 12.3-5 on page 299 of CLRS.

4. [40%] Implement a red-black tree class in Java.

(a) The keys are of type int.

(b) Your class shall be named as follows: 

ca.ucalgary.cpsc331.RedBlackTree

(c) Your class shall implement the following Java interface:
package ca.ucalgary.cpsc331;
public interface Dictionary {
boolean empty();
void insert(int key);
void delete(int key);
boolean member(int key);
}

(d) Your implementation shall raise an appropriate run-time exception when the user attempts to delete from an empty tree. 

(e) The class shall provide a constructor that does not take any arguments. This constructor initializes the tree to an empty one.

(f) The class shall override the toString() method. Your implementation of to String() shall return a String in the following format:
• The string consists of as many “lines” as there are internal nodes (i.e., a node that is not a leaf/NIL). If there are ten internal nodes, then there are ten lines. An empty tree is represented by an empty string.
• Each “line” is terminated by a newline character. No line shall contain leading or trailing whitespaces.
• Each line is a representation of an internal node. The order of the lines corresponds to a preorder tree walk.
• A line has the following format:

address:color:key
– key is the key stored in the node.
– color is either red or black, representing the color of the node.
– address is the tree address of the node, a concept explained below.
• The tree address of an internal node is defined inductively:
– The tree address of the root is the string “*”.
– If the tree address of an internal node n is the string s, then the tree addresses of the left and right children are respectively s + “L” and s + “R”. Here, + is the string concatenation operator.
For example, the left child of the right child of the root has the following tree address:
*RL 

CPSC 331 Information Structutes

Answer in Detail


Solved by qualified expert

Get Access to This Answer

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Hac habitasse platea dictumst vestibulum rhoncus est pellentesque. Amet dictum sit amet justo donec enim diam vulputate ut. Neque convallis a cras semper auctor neque vitae. Elit at imperdiet dui accumsan. Nisl condimentum id venenatis a condimentum vitae sapien pellentesque. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Malesuada fames ac turpis egestas maecenas pharetra convallis posuere. Et ultrices neque ornare aenean euismod. Suscipit tellus mauris a diam maecenas sed enim. Potenti nullam ac tortor vitae purus faucibus ornare. Morbi tristique senectus et netus et malesuada. Morbi tristique senectus et netus et malesuada. Tellus pellentesque eu tincidunt tortor aliquam. Sit amet purus gravida quis blandit. Nec feugiat in fermentum posuere urna. Vel orci porta non pulvinar neque laoreet suspendisse interdum. Ultricies tristique nulla aliquet enim tortor at auctor urna. Orci sagittis eu volutpat odio facilisis mauris sit amet.

Tellus molestie nunc non blandit massa enim nec dui. Tellus molestie nunc non blandit massa enim nec dui. Ac tortor vitae purus faucibus ornare suspendisse sed nisi. Pharetra et ultrices neque ornare aenean euismod. Pretium viverra suspendisse potenti nullam ac tortor vitae. Morbi quis commodo odio aenean sed. At consectetur lorem donec massa sapien faucibus et. Nisi quis eleifend quam adipiscing vitae proin sagittis nisl rhoncus. Duis at tellus at urna condimentum mattis pellentesque. Vivamus at augue eget arcu dictum varius duis at. Justo donec enim diam vulputate ut. Blandit libero volutpat sed cras ornare arcu. Ac felis donec et odio pellentesque diam volutpat commodo. Convallis a cras semper auctor neque. Tempus iaculis urna id volutpat lacus. Tortor consequat id porta nibh.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Hac habitasse platea dictumst vestibulum rhoncus est pellentesque. Amet dictum sit amet justo donec enim diam vulputate ut. Neque convallis a cras semper auctor neque vitae. Elit at imperdiet dui accumsan. Nisl condimentum id venenatis a condimentum vitae sapien pellentesque. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Malesuada fames ac turpis egestas maecenas pharetra convallis posuere. Et ultrices neque ornare aenean euismod. Suscipit tellus mauris a diam maecenas sed enim. Potenti nullam ac tortor vitae purus faucibus ornare. Morbi tristique senectus et netus et malesuada. Morbi tristique senectus et netus et malesuada. Tellus pellentesque eu tincidunt tortor aliquam. Sit amet purus gravida quis blandit. Nec feugiat in fermentum posuere urna. Vel orci porta non pulvinar neque laoreet suspendisse interdum. Ultricies tristique nulla aliquet enim tortor at auctor urna. Orci sagittis eu volutpat odio facilisis mauris sit amet.

Tellus molestie nunc non blandit massa enim nec dui. Tellus molestie nunc non blandit massa enim nec dui. Ac tortor vitae purus faucibus ornare suspendisse sed nisi. Pharetra et ultrices neque ornare aenean euismod. Pretium viverra suspendisse potenti nullam ac tortor vitae. Morbi quis commodo odio aenean sed. At consectetur lorem donec massa sapien faucibus et. Nisi quis eleifend quam adipiscing vitae proin sagittis nisl rhoncus. Duis at tellus at urna condimentum mattis pellentesque. Vivamus at augue eget arcu dictum varius duis at. Justo donec enim diam vulputate ut. Blandit libero volutpat sed cras ornare arcu. Ac felis donec et odio pellentesque diam volutpat commodo. Convallis a cras semper auctor neque. Tempus iaculis urna id volutpat lacus. Tortor consequat id porta nibh.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Hac habitasse platea dictumst vestibulum rhoncus est pellentesque. Amet dictum sit amet justo donec enim diam vulputate ut. Neque convallis a cras semper auctor neque vitae. Elit at imperdiet dui accumsan. Nisl condimentum id venenatis a condimentum vitae sapien pellentesque. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Malesuada fames ac turpis egestas maecenas pharetra convallis posuere. Et ultrices neque ornare aenean euismod. Suscipit tellus mauris a diam maecenas sed enim. Potenti nullam ac tortor vitae purus faucibus ornare. Morbi tristique senectus et netus et malesuada. Morbi tristique senectus et netus et malesuada. Tellus pellentesque eu tincidunt tortor aliquam. Sit amet purus gravida quis blandit. Nec feugiat in fermentum posuere urna. Vel orci porta non pulvinar neque laoreet suspendisse interdum. Ultricies tristique nulla aliquet enim tortor at auctor urna. Orci sagittis eu volutpat odio facilisis mauris sit amet.

Tellus molestie nunc non blandit massa enim nec dui. Tellus molestie nunc non blandit massa enim nec dui. Ac tortor vitae purus faucibus ornare suspendisse sed nisi. Pharetra et ultrices neque ornare aenean euismod. Pretium viverra suspendisse potenti nullam ac tortor vitae. Morbi quis commodo odio aenean sed. At consectetur lorem donec massa sapien faucibus et. Nisi quis eleifend quam adipiscing vitae proin sagittis nisl rhoncus. Duis at tellus at urna condimentum mattis pellentesque. Vivamus at augue eget arcu dictum varius duis at. Justo donec enim diam vulputate ut. Blandit libero volutpat sed cras ornare arcu. Ac felis donec et odio pellentesque diam volutpat commodo. Convallis a cras semper auctor neque. Tempus iaculis urna id volutpat lacus. Tortor consequat id porta nibh.

14 More Pages to Come in This Document. Get access to the complete answer.

If you want genuine assignment help in Australia, pay MyAssignmenthelp.com a visit. Apart from providing you with regular assignment help for different subjects, we also offer urgent assignment help for those students who need their assignments done quickly. Our online assignment help is fairly affordable, and you never have to worry about extravagant prices. Call us if you need assignment help.

More CPSC 331 CPSC 331 Information Structutes: Questions & Answers

COMPS413F Application Design and Development for Mobile Devices

Question:
This app is help the family members of patient who is recovering from kidney disease to take care of the patient, it contains diet recipes which is suitable to the patient and it may help them to recover. It contains the activities which could help them to be recovered.
Create a …

View Answer

CSE 1001 Computer Science

Task:
Note that each letter is represented exactly twice in the right diagram. The object of the game is to find as many matching pairs as possible. Each round of gameplay should do the following:
1.Print the board. Previously matched cards should show the matched letters.
2.Ask the player if the …

View Answer

SENG1050 Web Technologies

Task:
The objectives of this assignment are
to exercise your ability to create Web pages using HTML and CSS,
to transform the XML documents from Assignment 1 into HTML using XSLT,
to test your skill in employing HTML features such as forms,
to evaluate your expertise with JavaScript for cli …

View Answer

CMR 442 Current Issues and Innovation

Task:
1.Project Identification and Planning
Problem/Opportunity Identification Stage
1.What social or community problem do you want to solve, or what new product or service do you want to create? What opportunities do you see from the proposed innovation?
2.Who may benefit from solving the probl …

View Answer

Content Removal Request

If you are the original writer of this content and no longer wish to have your work published on Myassignmenthelp.com then please raise the
content removal request.

Choose Our Best Expert to Help You

Axel Benton

I did my Master’s in English Literature from the University of the West of England, Bristol

350 – Completed Orders

Hire Me

Jaydon Key

research scholar in Columbia University and am pursuing my doctorate degree in Physics.

300 – Completed Orders

Hire Me

Still in Two Minds? The Proof is in Numbers!

33845 Genuine Reviews With a Rating of 4.9/5.

Management

Assignment: 3 Pages, Deadline:
23 days

Good assignment and good support.It is important to review plagiarism and grammer

User ID: 3***11 Qatar

Finance

Assignment: 1 Page, Deadline:
3 days

This PowerPoint presentation is well-done. It fits well with this finance course and the individual did an excellent job. Thank you so much!

User ID: 8***35 Saint Louis, United States

Marketing

Assignment: 11.2 Pages, Deadline:
5 days

Good job done. The assignment is well written, can get higher grade if can provide more in-depth analysis on the topic

User ID: 8***66 Saint Louis, Hong Kong

Marketing

Home Work: 11 Pages, Deadline:
4 days

Overall well written essay, excellent and complete writing in one day, and the Expert prompt reply on comments

User ID: 8***66 Saint Louis, Hong Kong

HRM

Case Study: 8 Pages, Deadline:
6 days

Thanks for your effort. I appreciate it. I have grated 60, which is enough to pass.

User ID: 8***12 Dublin, Ireland

Finance

Home Work: 4 Pages, Deadline:
7 days

The excel formulas were perfect. But the explanation regarding the recommendation was subpar.

User ID: 5***90 Dublin, United States

Physics

Home Work: 1 Page, Deadline:
2 days

Wonderful as always! Very professional and knowledgeable! I love this experts work and always use them when it comes to Physics.

User ID: 6***06 Atlanta, United States

Healthcare

Assignment: 8 Pages, Deadline:
4 days

Really appreciate this work which help me to get 8.9 out of 10. i would like to express thanks to expert.

User ID: 5***91 Atlanta, Malaysia

Healthcare

Assignment: 12 Pages, Deadline:
7 days

Good work . it was help me lots. i got 6.5 out of 10 which is good score for me.

User ID: 5***91 Atlanta, Malaysia

Assignment

Essay: 5 Pages, Deadline:
3 days

amazing results, received a High grade thank you very much, appreciate the help. Can’t wait to have more assignments so you guys can help me.

User ID: 5***22 Atlanta, Switzerland

Assignment

Essay: 1 Page, Deadline:
3 days

Hello, Thanks for the quick delivery. And the job well done. looking forward to do more.

User ID: 5***06 Atlanta, Canada

Management

Essay: 4 Pages, Deadline:
4 days

Thanks for quick delivery. I will go through it and see what you have done. Yet to be graded

User ID: 5***06 Atlanta, Canada

Statistics

Course Work: 7 Pages, Deadline:
1 day

Great work- Job well done!! Work was completed before schedule.I Would highly recommend this service to others.

User ID: 8***59 Atlanta, United States

It Write Up

Assignment: 10 Pages, Deadline:
11 days

thank you a lot for helping me with the assignment and doing this so on time . you did exactly what i wanted you to do. i am very satisfied .

User ID: 8***43 Atlanta, Netherlands

Programing

Programming: 1 Page, Deadline:
10 days

thanks i had a good grade although it took so many back and forth i hope it wont happen again

User ID: 6***09 Atlanta, Philippines

Healthcare

Assignment: 1 Page, Deadline:
9 hours

Thanks for helping me understand my assignment and also helping me with the write up.

User ID: 8***87 Atlanta, United States

Accounting

Programming: 6.4 Pages, Deadline:
6 days

Excellent Service, Professional and Complete Writing. Will sure contact for further future assignments.

User ID: 8***38 Atlanta, Australia

Finance

Home Work: 2 Pages, Deadline:
3 days

Thankfully, I received one of the best marks awarded for the kind of work given. I am grateful to my assignment help team for their assistance

User ID: 2***85 Atlanta, Ghana

Business Law

Home Work: 1 Page, Deadline:
1 hour

Thank you for your service. Really appreciate that you make my assignment within time

User ID: 7***52 Atlanta, Canada

Management

Assignment: 2 Pages, Deadline:
7 days

Thank you Expert, my professor regraded my work and gave me a good grade this time. but he also mention that going forward i should be more detailed i …

User ID: 2***97 Upper Marlboro, United States

Management

Assignment: 3 Pages, Deadline:
23 days

Good assignment and good support.It is important to review plagiarism and grammer

User ID: 3***11 Qatar

Finance

Assignment: 1 Page, Deadline:
3 days

This PowerPoint presentation is well-done. It fits well with this finance course and the individual did an excellent job. Thank you so much!

User ID: 8***35 Saint Louis, United States

Marketing

Assignment: 11.2 Pages, Deadline:
5 days

Good job done. The assignment is well written, can get higher grade if can provide more in-depth analysis on the topic

User ID: 8***66 Saint Louis, Hong Kong

Marketing

Home Work: 11 Pages, Deadline:
4 days

Overall well written essay, excellent and complete writing in one day, and the Expert prompt reply on comments

User ID: 8***66 Saint Louis, Hong Kong

HRM

Case Study: 8 Pages, Deadline:
6 days

Thanks for your effort. I appreciate it. I have grated 60, which is enough to pass.

User ID: 8***12 Dublin, Ireland

Finance

Home Work: 4 Pages, Deadline:
7 days

The excel formulas were perfect. But the explanation regarding the recommendation was subpar.

User ID: 5***90 Dublin, United States

Physics

Home Work: 1 Page, Deadline:
2 days

Wonderful as always! Very professional and knowledgeable! I love this experts work and always use them when it comes to Physics.

User ID: 6***06 Atlanta, United States

Healthcare

Assignment: 8 Pages, Deadline:
4 days

Really appreciate this work which help me to get 8.9 out of 10. i would like to express thanks to expert.

User ID: 5***91 Atlanta, Malaysia

Healthcare

Assignment: 12 Pages, Deadline:
7 days

Good work . it was help me lots. i got 6.5 out of 10 which is good score for me.

User ID: 5***91 Atlanta, Malaysia

Assignment

Essay: 5 Pages, Deadline:
3 days

amazing results, received a High grade thank you very much, appreciate the help. Can’t wait to have more assignments so you guys can help me.

User ID: 5***22 Atlanta, Switzerland

Assignment

Essay: 1 Page, Deadline:
3 days

Hello, Thanks for the quick delivery. And the job well done. looking forward to do more.

User ID: 5***06 Atlanta, Canada

Management

Essay: 4 Pages, Deadline:
4 days

Thanks for quick delivery. I will go through it and see what you have done. Yet to be graded

User ID: 5***06 Atlanta, Canada

Statistics

Course Work: 7 Pages, Deadline:
1 day

Great work- Job well done!! Work was completed before schedule.I Would highly recommend this service to others.

User ID: 8***59 Atlanta, United States

It Write Up

Assignment: 10 Pages, Deadline:
11 days

thank you a lot for helping me with the assignment and doing this so on time . you did exactly what i wanted you to do. i am very satisfied .

User ID: 8***43 Atlanta, Netherlands

Programing

Programming: 1 Page, Deadline:
10 days

thanks i had a good grade although it took so many back and forth i hope it wont happen again

User ID: 6***09 Atlanta, Philippines

Healthcare

Assignment: 1 Page, Deadline:
9 hours

Thanks for helping me understand my assignment and also helping me with the write up.

User ID: 8***87 Atlanta, United States

Accounting

Programming: 6.4 Pages, Deadline:
6 days

Excellent Service, Professional and Complete Writing. Will sure contact for further future assignments.

User ID: 8***38 Atlanta, Australia

Finance

Home Work: 2 Pages, Deadline:
3 days

Thankfully, I received one of the best marks awarded for the kind of work given. I am grateful to my assignment help team for their assistance

User ID: 2***85 Atlanta, Ghana

Business Law

Home Work: 1 Page, Deadline:
1 hour

Thank you for your service. Really appreciate that you make my assignment within time

User ID: 7***52 Atlanta, Canada

Management

Assignment: 2 Pages, Deadline:
7 days

Thank you Expert, my professor regraded my work and gave me a good grade this time. but he also mention that going forward i should be more detailed i …

User ID: 2***97 Upper Marlboro, United States

Have any Query?

GET HELP WITH YOUR HOMEWORK PAPERS @ 25% OFF

For faster services, inquiry about  new assignments submission or  follow ups on your assignments please text us/call us on +1 (251) 265-5102

Write My Paper Button

WeCreativez WhatsApp Support
We are here to answer your questions. Ask us anything!
👋 Hi, how can I help?
Scroll to Top