I’m working on a algorithms & data structures project and need a sample draft to help me understand better.
Requirements:
Write a program to read an input sequence and then produce an array of links giving the values in ascending order. The first line of the input file is the length of the sequence (n) and each of the remaining n lines is a non-negative integer. The first line of the output indicates the subscript of the smallest input value. Each of the remaining output lines is a triple consisting of a subscript along with the corresponding input sequence and link values.
Getting Started:
1. Your program should read the input files by using Unix shell redirection (e.g. a.out<lab1.dat) to read the input from
stdin (C). By using redirection, it is unnecessary to explicitly open and close the input file, nor should your program
prompt for a file name. You should dynamically allocate tables for storing the input keys and the table of links. Unlike
the mergesort in Notes 1 and CLRS, the table of keys is never modified.
2. The link values are not initialized before the recursive mergesort begins. Each link will be initialized to -1 when its
sequence value is placed in a single-element list (at the bottom of the recursion’s “tree”).
3. The input sequence array and the link array may be global. Under this assumption, the following prototype may be used:
int mergeSort(int start, int count) where the start is the first subscript for a subarray of count elements. The returned int is the subscript of the first element in the resulting sorted sublist. The last element in the sublist will have a link value of -1.
4. The critical part of the code is a linear-time merge of two subarrays that previously had their link values set for ordered
sublists. (Be sure to understand the merging concept from pp. 3-4 of Notes 1 before proceeding.) The merge will revise
the link values to give a single ordered list.
5. If an input value appears more than once, those elements should be ordered by subscripts in the final list, i.e. your sort
code will be stable.
Consider the following input file:
8
5
5
2
4
3
1
0
1
The output (as subscript/value/link triples) will be:
First element is at subscript 6
0 5 1
1 5-1
2 2 4
3 4 0
4 3 3
5 1 7
6 0 5
7 1 2
Notice that the input sequence order has not changed.
Requirements: I want a full answer with an explanation as much as possible. Thank you! | C
Order any type of Service We Provide
We are the best assignment service that can satisfy student’s demands in different scientific fields. We perform tasks of any kind. Our specialists provide diverse custom assignment writing service to students from all over the world every day. You can contact us for assistance with:
The list is far from complete!
Representatives of our student assignment service are connoisseurs of the peculiarities of presentation in regards to academics. Your college assignment will never turn out an untoward surprise! Whether you need research for high school, an undergraduate program, or a Master’s or Doctoral degree, you will get exactly what you are looking for to sound smart and well-informed.
If you are pressed for time, request to our experts!
We are your academic saver. It is a perfect solution for people who need academic help but have no professionals nearby to provide it. Just redirect your home tasks to us and forget about any educational issues. With us, you will get 100% plagiarism-free content delivered on time by an experienced specialist in a particular field.
When you order professional assignments here, you will get:
Original custom papers. We value your academic reputation. Just as well, we value the years of thorough work on our reputation for reliability and never compromise the originality of delivered papers. We will never endanger both. Every custom assignment is written from zero – the only possible first stage of work on the order is research. We apply the latest plagiary checking tools on the final stage, so plagiarism has no chance to emerge in your college assignment writing.
Control over the order completion. To make the process of collaboration comfortable and efficient, we offer our clients to choose the writer themselves taking into account all the requirements and the budget. For you to save nerves, having entrusted your fateful task to some qualified “stranger”, we enable communication with the assigned writer in the process of order completion.
Affordable assistance. We are eager to contribute to the academic achievements of students in need of help with college assignments. We are eager to help you start investing in your career growth today. That is why our service is so affordable. We don’t charge to pay for the latest marketing tricks or advertisements – we choose the best experts in the labor market who write great custom papers in any area, level of complexity, and time frame. Our client’s grateful feedback is a top advertising trick.
On-time delivery. The quality of a paper is only valued when it is delivered within the determined time frame – you will get your custom assignment writing service in time and have a couple of days to revise it and ask for changes in case they are needed. And you will still have time to learn the material.
Protection. We value your trust and take all measures needed to keep your private and banking details safe. We offer only well-tested payment methods. Due to the system of encryption and protected servers, no third party can have access to your data.
Custom support 24/7. We do our best to make the process of collaboration comfortable for the customer. Our “write my assignment” help is always here for you to provide a solution to your problems, give you a prompt answer to any question, and offer clarification as to any issue related to the services. Feel free to contact us anytime!
If you feel that your dissatisfaction with student life is growing every day and you just feel exhausted, don’t hesitate to change the situation for the better today. Order your first assignment from reliable custom assignment services today to evaluate the advantages.
Having seen the difference once, you won’t want to go back to your previous lifestyle. You deserve to find fulfilment in other spheres of your life, have hobbies, spend time with close people but continue making progress. It is possible when you have a professional helper. Don’t put off your life for someday after graduation!
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more