Perform an insertion sort on the file pointed

Assignment Help Data Structure & Algorithms
Reference no: EM13161792

Using only the local data already supplied in FileSort, perform an insertion sort on the file pointed to by fd. Use lseeks for this; do not try to create any sort of array or list. An array-based version of insertion is supplied for your reference.

Do not modify this code

#include 
#include 
#include 

/*
void InsertSort(int vals[], int size) {
   int ndx, insNdx, toInsert;

   for (ndx = 1; ndx < size; ndx++) {
      toInsert = vals[insNdx = ndx];
      while (insNdx > 0 && toInsert < vals[insNdx-1]) {
         vals[insNdx] = vals[insNdx-1];
         insNdx--;
      }
      vals[insNdx] = toInsert;
   }
}
*/

void InsertSort(int fd) {
   size_t ndx, limit;
   int toInsert, temp;

}

int main() {
   int fd, data;

   fd = open("temp.txt", O_CREAT|O_RDWR|O_TRUNC, 0600);
   while (EOF != scanf("%d", &data))
      write(fd, &data, sizeof(int));

   InsertSort(fd);

   lseek(fd, 0, SEEK_SET);
   while (0 != read(fd, &data, sizeof(int)))
      printf("%d ", data);
   printf("\n");

   return 0;
}

 

 

Reference no: EM13161792

Questions Cloud

Function which correctly sorts three : Write an x8086 HLA Assembly language program that implements a function which correctly sorts three parameters and returns a boolean value in AL which should be set to true if any swaps were performed to sort the sequence in increasing order.
Cashregister class that can be used with the retailitem clas : Write a CashRegister class that can be used with the RetailItem class that you wrote in Part 1. The CashRegister class should simulate the sale of a retail item. It should have a constructor that accepts a RetailItem object as an argument.
Shows the users name and program name : Java program, the program has a page that shows the users name and program name. a second jpanel that shows 4 buttons (circle square rectangle and oval) the problem i am having is that my program is not dropping where i click and the shapes are not s..
The program should not accept quantities : Input Validation: The program should not accept quantities, or wholesale or retail costs, less than 0. The program should not accept dates that the programmer deter- mines are unreasonable.
Perform an insertion sort on the file pointed : Using only the local data already supplied in FileSort, perform an insertion sort on the file pointed to by fd. Use lseeks for this; do not try to create any sort of array or list. An array-based version of insertion is supplied for your reference.
Using matlab and for loops : Using MATLAB and for loops, provide an animation that follows the below steps: Start with a square at the origin with each side being 5 units long. Imagine someone kicked the box and animate it moving on a projectile motion trajectory. Hint: look at ..
Postorder traversal print a heap in sorted order? : Will preorder, inorder, or postorder traversal print a heap in sorted order? why or why not? use the following numbers to prove your point 85 86 88 89 90 91 92
Compute the union and intersection of two sets : How can you compute the union and intersectio of two sets, using some of the methods that the set interfce provides? hint: your code should not be bigger than four lines
Public boolean chackanagram : write the anagramList() chackanagram. checkAnagram returns true if its two Word parameters have original words that are nagrams. If not, checkAnagram returns false. use the ethod header below to write checkanagram. Assume that all Word methods work a..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Design analgorithm that decides for each node

Design an O(n) algorithm that decides (schedules) for each node at which time slot to start sending data such that the total number of time (slots) is minimized.

  Design algorithm to produce list of customers

Design an algorithm to produce a list of customers from the Glad Rags Clothing Company's customer master file. Each record on the customer master file contains the customer's number.

  Studying in major paralegal

Make a Microsoft Word document which includes a table and hyperlinks to Web sites helpful to someone studying in your main Paralegal.

  Evaluate the average complexity of an enqueue operation

Evaluate the average complexity of an enqueue operation. Determine the average complexity of the dequeue (remove) operation.

  System analyst

A huge, well regarded supplier of key raw materials to your corporation's production process requires a year-end summary report of totals purchased from it.

  Define an enumeration type called response

define an enumeration type called Response with the possible values Yes, No, and Maybe. Yes should be 1, No should be 0, and-1

  Sketch flowchart for logic of program to enter three values

Sketch a flowchart or write psuedocode to represent logic of a program that alllows the user to enter three values .

  Algorithm for string of numbers recognize all the substrings

Write down algorithm, using pseudocode, to perform the following task, Given a string of numbers, recognize all of the substrings that form numbers that are divisible by 3.

  Creating visual studio asp .net web site

Make a Visual Studio 2008 ASP .NET Web Site with 2-Web Forms. Add a DropDownList server control and a Label server control to 1st Web Form.

  What do you meant by an rfp

Select a specific category of vertical applications to investigate. Use the Internet and any other sources of information you might have to study some of the different products that are available in that category.

  Create algorithm to read arbitrary number of data record

Create the algorithm to read arbitrary number of data records, each containing name, age, and code. Code of 1 will indicate female, a code of 2 will indicate male.

  Explain the sorting techniques selection sort

Explain the following sorting techniques using appropriate algorithms- (i) selection sort (ii) bubble sort

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd