Answer:
This is an infinite loop.
Explanation:
The while loop while never end since the last statement inside the while loop will continue to decrement the value of num by 1 and the condition num < 9 will always be true.
So either change the condition of the while loop like: num > -9
or start incrementing the variable num in the last statement of the while loop like:
num = num + 1
Note: Don't make both changes at the same time.
Visit: gotit-pro.com for fastest, top-notch and impeccable homework and exams help in a range of subjects and ace your academics.
Thanks and Best Regards: Your Friendly Study Co-Pilot
Answer:
it stores the largest value in list (the maximum) in foo
Explanation:
Initially foo is assigned as the first element of the list
Inside the loop, every element in the list will be compared with foo, starting from the second element. If an element is greater than foo, the new value of the foo will be that element. At the end of the loop, foo will be equal to the largest element in the list.
Answer:
Check the explanation
Explanation:
CPI means Clock cycle per Instruction
given Clock rate 600 MHz then clock time is Cー 1.67nSec clockrate 600M
Execution time is given by following Formula.
Execution Time(CPU time) = CPI*Instruction Count * clock time = 
a)
for system A CPU time is 1.3 * 100, 000 600 106
= 216.67 micro sec.
b)
for system B CPU time is 
= 333.33 micro sec
c) Since the system B is slower than system A, So the system A executes the given program in less time
Hence take CPU execution time of system B as CPU time of System A.
therefore
216.67 micro = =
Instructions = 216.67*750/2.5
= 65001
hence 65001 instruction are needed for executing program By system B. to complete the program as fast as system A
Equal sign (=)
hope so !!!
Answer:
see explaination
Explanation:
#include <iostream>
#include <string>
using namespace std;
class LinkedList{
class Node{
public :
int data;
Node* next;
Node(int data){
this->data = data;
next = NULL;
}
};
public :
Node *head;
LinkedList(){
this->head = NULL;
}
void insert(int d){
Node* new_node = new Node(d);
new_node->next = head;
head = new_node;
}
// sort the list with selection sort algorithm.
// Pick the smallest element in the unsorted array and place in the first element in the unsorted.
void sort_list(){
if (head == NULL){
return;
}
Node* current = head;
while (current->next != NULL){
Node* min_node = current;
Node* traverse = current->next;
while(traverse != NULL){
if(traverse->data < min_node->data){
min_node = traverse;
}
traverse = traverse->next;
}
int temp = current->data;
current->data = min_node->data;
min_node->data = temp;
current = current->next;
}
}
void print_list(){
Node* current = head;
while(current !=NULL){
cout<<current->data<<" ";
current = current->next;
}
cout<<"\n";
}
};
int main(){
LinkedList ll;
for(int i=0;i<10;i++){
ll.insert(i);
}
ll.print_list();
cout<<"*******************************************\n";
ll.sort_list();
ll.print_list();
cout<<"*******************************************\n";
}