Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MUST ONLY USE C++ TERMS NO JAVA USAGE AT ALL Develop a highly modularized C++ pr

ID: 3677922 • Letter: M

Question

MUST ONLY USE C++ TERMS

NO JAVA USAGE AT ALL

Develop a highly modularized C++ program that will sort a set of numbers using a modified binary sort algorithm while maintaining a doubly linked sorted list. Use pointers to build the linked list. Give the user the option to view every step of the sorting process (this verbose option will print each step to the user’s monitor). Read the input from a file specified by the user. Leave the sorted output in a file, and inform the user the name of the file before exiting. Do not remove any duplicates found. Need More info go to http://tinyurl.com/h6up5qx

Here is a sample input file:

18 10 29 21 10 26 38 8 28 32 10 12 48 2 2 49 2 15 49 3 25 59 1 22

53 4 9 76 8 20 79 4 28 81 5 28 81 6 81 10 18 86 5 9 95 5 20

98 11 23 0 3 30 2 4 8 6 6 10 6 8 10 6 9 10 8 1 7 9 4 4

Explanation / Answer

Hi below i have written a code that helps you understand for your reference,

/* Program to insert in a sorted list */

#include<stdio.h>

#include<stdlib.h>

/* Link list node */

struct node

{

    int data;

    struct node* next;

};

/* function to insert a new_node in a list. Note that this

  function expects a pointer to head_ref as this can modify the

  head of the input linked list (similar to push())*/

void sortedInsert(struct node** head_ref, struct node* new_node)

{

    struct node* current;

    /* Special case for the head end */

    if (*head_ref == NULL || (*head_ref)->data >= new_node->data)

    {

        new_node->next = *head_ref;

        *head_ref = new_node;

    }

    else

    {

        /* Locate the node before the point of insertion */

        current = *head_ref;

        while (current->next!=NULL &&

               current->next->data < new_node->data)

        {

            current = current->next;

        }

        new_node->next = current->next;

        current->next = new_node;

    }

}

/* BELOW FUNCTIONS ARE JUST UTILITY TO TEST sortedInsert */

/* A utility function to create a new node */

struct node *newNode(int new_data)

{

    /* allocate node */

    struct node* new_node =

        (struct node*) malloc(sizeof(struct node));

    /* put in the data */

    new_node->data = new_data;

    new_node->next = NULL;

    return new_node;

}

/* Function to print linked list */

void printList(struct node *head)

{

    struct node *temp = head;

    while(temp != NULL)

    {

        printf("%d ", temp->data);

        temp = temp->next;

    }

}

/* Drier program to test count function*/

int main()

{

    /* Start with the empty list */

    struct node* head = NULL;

    struct node *new_node = newNode(5);

    sortedInsert(&head, new_node);

    new_node = newNode(10);

    sortedInsert(&head, new_node);

    new_node = newNode(7);

    sortedInsert(&head, new_node);

    new_node = newNode(3);

    sortedInsert(&head, new_node);

    new_node = newNode(1);

    sortedInsert(&head, new_node);

    new_node = newNode(9);

    sortedInsert(&head, new_node);

    printf(" Created Linked List ");

    printList(head);

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote