Questions
Insertion sort, which is one of the other sorting techniques introduced in this chapter. Create an...

Insertion sort, which is one of the other sorting techniques introduced in this chapter. Create an algorithm to implement an insertion sort.


Methods for sorting data files. You should produce a brief report discussing the different sorting options that can be used.


In: Computer Science

Write a script that will output a table where the rows and cells are labeled. The...

Write a script that will output a table where the rows and cells are labeled. The script should be versatile, so one could easily change the number of rows and cells the script should output. For this exercise have the script create a table with 15 rows and 5 cells. Refer to the tables lesson for information on how to create a table. You need to write all the PHP functionality above the doctype and display the resulting HTML string via a variable in the echo statement within the body element

In: Computer Science

Discuss the issues involved in sorting large data files. Explain how indexing is used to overcome...

Discuss the issues involved in sorting large data files. Explain how indexing is used to overcome this issue.


Explain the difference between physical order and logical order


In: Computer Science

*** In C++ Write a program that converts from 24-hour notation to 12-hour notation. For example,...

*** In C++

Write a program that converts from 24-hour notation to 12-hour notation. For example, it should convert 14:25 to 2:25 P.M. The input is given as two integers.

This is what I have so far. The program runs for correct input values, but I cannot figure out how to accommodate for hours > 23 and minutes > 59, or negative values. My code is below:

// Writing a program that converts from 24-hour notation to 12-hour notation.//

#include

using namespace std;

void input(int&, int&, char&);
void convert(int&, int&, char&);
void output(int&, int&, char&);

int main()
{
   int hours, minutes;
   char ampm; //character value to determine am/pm
   char again; //run the program again

   //loop for re-running program
   do
   {
       input(hours, minutes, ampm);
       convert(hours, minutes, ampm);
       output(hours, minutes, ampm);

       cout << endl << "Enter Y to run again, or any other key to exit: ";
       cin >> again;
   }
   while (again == 'y' || again == 'Y');

   return 0;
}

void input(int& hours, int& minutes, char& ampm)
{
   //loop for input and checking for invalid input
  
   cout << "Enter time in 24hr format HH:MM ";
   cin >> hours;
   cin.get();
   cin >> minutes;
  
   do
   {
       if (hours > 23 || hours < 0) cout << "Please enter a value between 0 and 23" << endl;
   }
   while (hours > 23);
}

void convert(int& hours, int& minutes, char& ampm)
{
   //designates PM if hour is above 12, and reduces to 12hr format
   //*** try >= to reduce to two lines
   if (hours > 12)
   {
       hours = hours - 12;
       ampm = 'p';
   }
   else if (hours == 12) ampm = 'p';
   else ampm = 'a';
}

void output(int& hours, int& minutes, char& ampm)
{
   if (ampm == 'p')
   {
       if (minutes < 10) cout << hours << ":0" << minutes << " P.M.";
       else cout << hours << ":" << minutes << " P.M.";
   }
   else
   {
       if (minutes < 10) cout << hours << ":0" << minutes << " A.M.";
       else cout << hours << ":" << minutes << "A.M.";
   }
}

In: Computer Science

#include <stdio.h> #define MAX 8 //Byte = 8 bits void func_and(int a[], int b[], int result[])...

#include <stdio.h>
#define MAX 8 //Byte = 8 bits

void func_and(int a[], int b[], int result[]) {
    for(int i=0; i < MAX; i = i + 1){
        result[i] = a[i] & b[i];
        }
    }

void func_or(int a[], int b[], int result[]) {
    for(int i=0; i < MAX; i = i + 1){
        result[i] = a[i] || b[i];
    }
}

void func_not(int a[], int result[]) {
    for (int i = 0; i < MAX; i = i + 1) {
        result[i] = !a[i];
    }
}

void func_1s_comp(int a[], int result[]) {
    for (int i = 0; i < MAX; i = i + 1) {
        result[i] = !a[i];
    }
}

void func_2s_comp(int a[], int result[]) {

    for (int i = 0; i < MAX; i = i + 1) {

        result[i] = !a[i];

        if(result[i] == '1' && carry == 1)
        {
            compTwo[i] = '0';
        }
        else if(result[i] == '0' && carry == ddd1)
        {
            compTwo[i] = '1';
            carry = 0;
        }
        else
        {
            compTwo[i] = result[i];
        }

        compTwo[MAX] = '\0';
    }
}


int main(void) {

    int choice;
    int carry = 1;
    int compTwo[];
    int x[MAX];
    int y[MAX];
    int z[MAX];

    do {

        printf("Enter the command number: \n0. Exit\n1. AND\n2. OR\n3. NOT\n4. 1's complement\n5. 2's complement\n6. 2's complement*\n");
        scanf("%d", &choice);

        switch (choice) {

            case 0: //Exit

                break;

            case 1: //AND

                printf("Enter the first binary number: \n");
                for (int i = 0; i < MAX; i = i + 1) {
                    scanf("%d", &x[i]);
                }

                printf("Enter the second binary number: \n");
                for (int i = 0; i < MAX; i = i + 1) {
                    scanf("%d", &y[i]);
                }

                func_and(x, y, z);

                printf("The first number AND second binary yield: ");
                for (int i = 0; i < MAX; i = i + 1) {
                    printf("%d", z[i]);
                }
                printf("\n");

            case 2: //OR

                printf("Enter the first binary number: \n");
                for (int i = 0; i < MAX; i = i + 1) {
                    scanf("%d", &x[i]);
                }

                printf("Enter the second binary number: \n");
                for (int i = 0; i < MAX; i = i + 1) {
                    scanf("%d", &y[i]);
                }

                func_or(x, y, z);

                printf("The first number OR second binary yield: ");
                for (int i = 0; i < MAX; i = i + 1) {
                    printf("%d", z[i]);
                }
                printf("\n");

            case 3: //NOT

                printf("Enter the binary number: \n");
                for (int i = 0; i < MAX; i = i + 1) {
                    scanf("%d", &x[i]);
                }

                    func_not(x, z);

                    printf("The NOT for this number is: ");
                    for (int i = 0; i < MAX; i = i + 1) {
                        printf("%d", z[i]);
                    }
                    printf("\n");


            case 4: //1's complement

                printf("Enter the binary number: \n");
                for (int i = 0; i < MAX; i = i + 1) {
                    scanf("%d", &x[i]);
                }

                func_1s_comp(x, z);

                printf("The 1st complement of this binary number is: ");
                for (int i = 0; i < MAX; i = i + 1) {
                    printf("%d", z[i]);
                }
                printf("\n");


            case 5://2's complement

                printf("Enter the binary number: \n");
                for (int i = 0; i < MAX; i = i + 1) {
                    scanf("%d", &x[i]);
                }

                func_2s_comp(x, z);

                printf("The 2nd complement of this binary number is: ");
                for (int i = 0; i < MAX; i = i + 1) {
                    printf("%d", z[i]);
                }
                printf("\n");

            case 6://2's complement*
                        break;
                }
        }

        while (choice != 0);

        return 0;
}

I just have to add 2's complemenet and 2* complement which in the 2 functions which I dont know how to do. 2* complement is "Start from the right to left until you see digit 1, then pass it and NOT the digits after that. For instance, 2’s complement of 110100 is 001100"

In: Computer Science

Creating a list/tuple 3.Given a list of tuples containing student first names and last names e.g....

Creating a list/tuple

3.Given a list of tuples containing student first names and last names e.g. (“John”, “Doe”) that represents a class. Ask the user for a students first and last name and check if that student is a member of the class.

In: Computer Science

Prove the following: If a heap has one new leaf added that does not satisfy the...

Prove the following:

If a heap has one new leaf added that does not satisfy the condition that the leaf is greater than its parent, then sifting that leaf up until it is greater than its parent will produce a heap.

In: Computer Science

write a java program of mickey mouse it can be simple with just ears face eyes...

write a java program of mickey mouse it can be simple with just ears face eyes and mouth

In: Computer Science

VI. Answer part A, B, and C of question 5. 5a) Given a String str1 and...

VI. Answer part A, B, and C of question 5.

5a)

Given a String str1 and a String str2, return true if str1 contains any character in str2


anyChar("abc", "xyz") → false
anyChar("abc", "xya") → true
anyChar("abc", "xyzxyzbxyzxyz") → true

5b)

Given a String str1 and a String str2, return true if str1 does not contains any character in str2, and false otherwise.

noChar("abc", "xyz") → true
noChar("abc", "xya") → false
noChar("xyzxyzbxyzxyz", "xyzb") → false

5c)

Given a String str1 and a String str2, return true if str1 contains every character in str2. The empty string is contained in any other String, including the empty string itself.


everyChar("abc", "xyz") → false
everyChar("abc", "xya") → false
everyChar("xyzxyzbxyzxyz", "xyzb") → true

In: Computer Science

can anyone summarize this? Robotics and technology have always been something that has been said will...

can anyone summarize this?

Robotics and technology have always been something that has been said will “rule the world” someday, and part of that is true! It starts out when they begin taking jobs! One of the most common jobs, in my eyes, that has been taken over by robotics, is proofreading! (Bernazzani, S., N/A) In software like Google Docs and Microsoft Word, we have the ability to tell the computer to proofread our papers, to make sure spelling and punctuation is correct. Another job that has been taken by robots, is a Pin Setter, for bowling! (Jamie Harris, October, 2018) Some advantages of robotics taking over automating production tasks, is how much more efficiently this can be done, how much more product can be made quicker, as well as saving money from paying employees. Some disadvantages that this has is that the employees are left looking for another job, and if the machinery were to ever go down, the engineer of the robot would have to come out to replace whatever broke, which then takes more time to replace, rather than having another employee cover for each other if something comes up.

I think robots will affect the society in the future by taking over the world, literally. In McDonald’s Fast Food, there is now a menu where you pick your order yourself, rather than talking to a cashier at the front desk. Pretty soon, we will have robotics that can do any and everything for us. I like to think of it as the movie Wall-E. Yes, the robotics idea sounds great in the beginning, but there is always the possibility that it goes too far, and we can not do anything to fix the situation.

and feedback

In: Computer Science

a. Write short notes about smartwatch. What features a smartwatch could serve? b. Imagine you have...

a. Write short notes about smartwatch. What features a smartwatch could serve?

b. Imagine you have a friend named smith, who likes to draw and do illustrations and now he is looking to buy a device where he can do illustrations and also teach students online for tuition. What device would you suggest to your friend and why?

c. Suppose smith have a pc with intel core i7, 16 GB RAM and 500 GB HDD. But recently, he has noticed that his pc is running slow. What could be the problem? What could be the solution?

In: Computer Science

Brewster’s Used Cars, Inc. employs several salespeople. Brewster, the owner of the company, has provided a...

Brewster’s Used Cars, Inc. employs several salespeople. Brewster, the owner of the company, has provided a file that contains sales records for each salesperson for the past month. Each record in the file contains the following two fields:

The salesperson’s ID number, as an integer

The amount of a sale, as a real number

The records are already sorted by salesperson ID. Brewster wants you to design a program that prints a sales report. The report should show each salesperson’ssales and the total sales for that salesperson. The report should also show the total sales for all salespeople for the month. Here is an example of how the sales report should appear:

Brewster's Used Cars, Inc.

Sales Report

Salesperson ID

Sale Amount

===========================================

100

$10,000.00

100

$12,000.00

100

$5,000.00

Total sales for this salesperson: $27,000.00

101

$14,000.00

101

$18,000.00

101

$12,500.00

Total sales for this salesperson: $44,500.00

102

$13,500.00

102

$14,500.00

102

$20,000.00

Total sales for this salesperson: $48,000.00

Total of all sales: $119,500.00

I need help making a flowchart in Raptor with sub Modules.

In: Computer Science

1. Enhance Binary System Conversion program with Lab05.2 Addition Function Write a program that accepts two...

1. Enhance Binary System Conversion program with Lab05.2 Addition Function Write a program that accepts two positive binary number in string and perform the addition with Lab05.2 function enhance in a way can accept binary string in addition to decimal string (use input parameter to control the base2 or base10 addition) and output the as binary string. (Optional: Demonstrate 8 bits and 16 bits in length as inputs.) // the example function prototype for addition function below where accepting two numbers, m, and base as input; output the addition result as string type as return value; base should be 2 or 10 as required. string addFunction(string numberA, string numberB, int m, int base); Requirement: C++ programing; program an addition algorithm function that can both accept binary and decimal addition; convert each other if necessary. ................................................................................................................................................................................................................

Requirement:

1. Write a string addFunction that both can accept two positive binary numbers and decimal numbers in string.

2. The example function prototype for addition function below where accepting two numbers,m, and base as input; output the addition result as string type as return value; base should be 2 or 10 as required.

3. Output needs as binary string.

4. Example for String addFuntion(string numberA, string number B, int m, int base).

Program language: C++

In: Computer Science

I'm trying to code in MIPS (MIPS Assembly Language) to calculate the hamming distance between two...

I'm trying to code in MIPS (MIPS Assembly Language) to calculate the hamming distance between two integers. Ideally, the program would ask for the user to type in the two integers. Then, the program would calculate the hamming distance. Afterward, it would ask if you'd like to find another hamming distance. If the user says yes, it would loop back to the beginning and ask for two new integers.

Below is the code that I've created so far. Guidance with an explanation would be much appreciated! If creating a program from scratch (or if you have a similar program available that would demonstrate hamming distance in assembly), I'd be grateful! I want to examine working code to create my own version, but the code below is not working,

Thank you!

.data #Data section

.data   

prompt1:    .asciiz      "Enter the first number: "

prompt2:    .asciiz      "Enter the second number: "

resultText:    .asciiz      "Hamming Distance is: "

menu:     .asciiz      "Do you want to calculate Hamming Distance again? /n1)Yes /n2)No"   

.text

.globl main

main:

hammingProcess:

#ask the user to provide the first number

li $v0, 4     #command for printing a string

la $a0, prompt1 #loading the string to print into the argument to enable printing

syscall      #executing the command

#read the first number provided by the user

li $v0, 5    #command for reading an integer

syscall      #executing the command for reading an integer

move $t0, $v0     #moving the number read from the user input into the temporary register $t0

#ask the user to provide the second number

li $v0, 4    #command for printing a string

la $a0, prompt2    #loading the string into the argument to enable printing

syscall      #executing the command

#read the second number to be provided to the user

li $v0, 5    #command to read the number provided by the user

syscall      #executing the command for reading an integer

move $t1, $v0    #moving the number read from the user input into the temporary register $t1

xor $t8,$t0,$t1    #this xors the values stored in $t0 and $t1 and assigns them to the temporary register $t8

    la $t8,resultText      

    li $v0,4

    syscall        

       move $a0, $zero    # $a0 will hold the result

loop:

    bgez $t3, skip     # test the most significative bit of $t3

    sll $t3, $t3, 1    # (*) [NOTE below] shift left $t3 one bit

    addiu $a0, $a0, 1 # If bit was set, increment result

skip:   

    bnez $t3, loop     # loop while not done

    li $v0,1

    syscall

    la $a0,resultText2    

    li $v0,4

    syscall        

#The following block of code is to pre-load the integer values for the various instructions into registers for storage

li $t4, 1    #This is to load the immediate value of 1 into the temporary register $t4

li $t5, 2    #This is to load the immediate value of 2 into the temporary register $t5

la $a0, menu    #loading the string into the argument to enable printing

syscall      #executing the command

#the next block of code is to read the number provided by the user

li $v0, 5    #command for reading an integer

syscall      #executing the command

move $t2, $v0    #this command is to move the integer provided into the temporary register $t2

beq $t2,$t3,exitProcess    #Branch to 'exitProcess' if $t2 = 1

beq $t2,$t5,hammingProcess #Branch to 'hammingProcess' if $t2 = 2

exitProcess:

li $v0, 10

syscall

#This is to terminate the program

# END OF PROGRAM

In: Computer Science

I need this code translated from C++ to Java. Im personally still trying to learn Java,...

I need this code translated from C++ to Java. Im personally still trying to learn Java, so if you can include screenshots of your IDE/output that would be helpful. Much appreciated!

#include <iostream>
#include <string>
using namespace std;

class pizza
{
public:
   string ingrediants, address;
   pizza *next;
   pizza(string ingrediants, string address)
   {
       this->address = address;
       this->ingrediants = ingrediants;
       next = NULL;
   }
};

void enqueue(pizza **head, pizza **tail, pizza *thispizza)
{
   if (*head == NULL) *head = thispizza;
   else (*tail)->next = thispizza;
   *tail = thispizza;
   return;
}

pizza* dequeue(pizza **head, pizza **tail)
{
   pizza* pizzatodeliver = NULL;
   if (*head != NULL)
   {
       pizzatodeliver = *head;
       *head = (*head)->next;
   }
   if (*head == NULL) *tail = NULL;
   return pizzatodeliver;
}

void deliver(pizza **head, pizza** tail)
{
   pizza *thispizza = dequeue(head, tail);
   if (thispizza == NULL)
   {
       cout << "No deliveries pending" << endl; return;
   }
   cout << "Deliver a pizza with " << thispizza->ingrediants
       << " to " << thispizza->address << endl;
}

int main()
{
   pizza *first = NULL, *last = NULL;

   enqueue(&first, &last, new pizza("pepperoni", "1234 Bobcat Trail"));
   enqueue(&first, &last, new pizza("sausage", "2345 University Drive"));
   deliver(&first, &last);
   enqueue(&first, &last, new pizza("extra cheese", "3456 Rickster Road"));
   enqueue(&first, &last, new pizza("everything", "4567 King Court"));
   enqueue(&first, &last, new pizza("coffee beans", "5678 Java Circle"));
   deliver(&first, &last);
   deliver(&first, &last);
   deliver(&first, &last);
   deliver(&first, &last);
   deliver(&first, &last);

   cin.get(); return 0;
}

In: Computer Science