Devonrevenge's stuck on a coursework question about binary search trees please help

You are given a pile of tests with students names in them. you need to find a particular paper. should you use linear or binary search? why?

Now I just explained in the work how a binary search tree works and what it is without psoudo code, I di a diagram of the tree etc, just I was searching for a sorted list, now I got names to deal with...

so I not necisarily need to know how to code it, I could right the code hapily, I just want to know what the question is asking like do I explain how a code would work with enum names in, or explain how the key could be checked against the name?

and I have no idea how to present it cos I never wents to school school :/

How do you present the answers to these questions for Uni?

thank you so much for any input that is genuinley helpful, remember Im not fishing for an answer, just want to know how to present it.


if you want to help more....


for the next question it says im given a list of names with co responding 6 digit id nums... it wants me to A, find the student whos number is x

then it asks if I can use a binary search for one of the names (is it asking if I can use names to search alphanumericaly??)

lastly I have no idea what this question is even saying

you want to make a new version list ordered alphabeticaly by name, choose an algorythm for ALTERING the directory. use algorythm to re-order the forst ten entries, and keep track of the number of comparisons....


^what the hell is that even saying, its not even words, this person is worse at communicating than me, have no idea what it means, how am I gonna survive uni if they ask questions that dont translate to reality
Last edited on
I'm not sure what you are asking. I can't tell what you question even is because there appear to be multiple questions. Should have used formatting as you can't tell where you question(s) are compared to the assignments questions.
for the first question, do I explain about name value pairs, or names being associated to values in a 2d array, or something else I have over looked?
It's hard to answer those questions because they are based around what you are learning in uni and what you have learned before. So if you give an answer from us that is more advanced than what you have learned then the instructor may deduct more points due to knowing you got help on it.
Binary search is generally faster than linear search -- but there's a catch: binary search only works if the list is sorted. So if the list isn't sorted, you must go with linear search.

Also, a Binary Search Tree (BST) is a data structure... a binary search is an algorithm that works on lists/arrays that are sorted (basically emulating a BST).

Searching a BST is not called a "binary search". A binary search doesn't search a binary search tree, it searches a sorted list or sorted array.

http://en.wikipedia.org/wiki/Binary_search_algorithm

you want to make a new version list ordered alphabeticaly by name, choose an algorythm for ALTERING the directory. use algorythm to re-order the forst ten entries, and keep track of the number of comparisons....

Maybe you want to re-read whatever was before this paragraph for context? I don't know what directory it's talking about.
Everyone on my course has no idea what is meant by the questions in the context, we were just taught to code ourselves a binary search code for searching sorted lists
Hey when I finish my work can I send links to the questions and answers, maybe I could get some feedback before the deadline instead?
It looks pretty straight forward, your professor wants to know which method you would use and why you would choose that method over any alternative options presented. You could stretch this out to maybe a three sentence answer but he won't be expecting much more then that.

I just want to state the obvious for a second and complain about how this is a really stupid work problem. If your teacher thinks it's possible to write code that searches through a physical stack of papers then he has either unlocked some huge secret of the universe or he has gone off the deep end.</rant>

For your second part:

- Part 'A' is easy, this is what std::map is for.

- Part 'B'(?) Yes, you just would have to sort them first. The only confusing part here is if he means "Can you immediately use a binary search to find a student by name?" or if he will allow the intermediate step.

- Are you sure you typed that third part correctly? I can usually talk to toddlers who don't have fully developed communications skills yet and that paragraph STILL doesn't make a lot of sense to me.
these are his words computer geek, and lol by the way, am gonna tell my fellow students hes like toddler HAHA, maybe I will get the questions of the net to you guys
Last edited on
For the first question it sounds like the papers are unsorted and then you can't do a binary search, so you must do a linear search.

The second question is the most confusing. If I had to guess, it is asking wether or not you can have a single container holding pairs of students names and id's, and do a binary search on both name and ID. If this is the question, the answer is no because they must either be sorted by name or id, but not both. And again binary search only works or sorted data. You might have two containers, one sorted by name, and another by id, then you could do it.

The last question sounds like you are asked to come up with an algorithm for sorting by name. Since you're studying binary search, why not use tree sort? Just build a binary search tree out of the first ten in the list, then traverse it in order.
Last edited on
Topic archived. No new replies allowed.