Answer:
The program to this question as follows:
Program:
#include<iostream> //include header file.
using namespace std; //using name space.
int main() //main function.
{
int n,i,key; //define variable.
int a[n]; //define array
cout<<"Enter size of array :"; //message.
cin>>n; //input number from user.
cout<<"Enter array elements :"; //message
for(i = 0;i<n;i++) //loop
{
cin>>a[i]; //input array elements
}
cout<<"Enter a number:"; //message
cin>>key; //input number.
for(i = 0;i<n;i++) //loop
{
if(a[i]<=key) //if block
{
cout<<a[i]<<"\n "; //print array elements
}
}
return 0;
}
Output:
Enter size of array :7
Enter array elements :5
50
50
75
100
200
140
Enter a number:100
5
50
50
75
100
Explanation:
The description of the above program as follows:
- In this program first, we include a header file and define the main method in method we define variables and array that are "n, i, key and a[]". In this function, all variable data type is "integer".
- The variable n is used for the size of array and variable i use in the loop and the key variable is used for comparing array elements. Then we use an array that is "a[]" in the array, we use the for loop to insert elements form user input.
- Then we define a loop that uses a conditional statement in if block we check that array elements is less than and equal to a key variable. If this value is true so, we will print the remaining elements.
Answer:
b) Single source shortest path
Explanation:
These are the options for the question
a) All pair shortest path
b) Single source shortest path
c) Network flow
d) Sorting
Dijkstra's algorithm is algorithm by
Edsger Dijkstra arround the year 1956, this algorithm determine the shortest path, this path could be between two nodes/vertice of a graph.
The steps involves are;
✓setting up of the distances base on the algorithm.
✓ calculation of the first vertice up to vertice adjacent to it
✓The shortest path result.
It should be noted that maximum number of times the decrease key operation performed in Dijkstra's algorithm will be equal to Single source shortest path.
Answer:
Make use of hash tables
Explanation:
The appropriate thing to use for this should be a hash table.
A Hash Table can be described as a data structure which stores data in an associative manner. In a hash table, data is stored in an array format, where each data value has its own unique index value. Access of data becomes very fast if we know the index of the desired data. So we can perform Hashing on ISBN Number since its unique and based on the Hash Function w ecan store the Information record.
There is no requirement for printing the file in order - HashTables dont store the data in order of insertions, so no problems with that
It becomes a data structure in which insertion and search operations are very fast irrespective of the size of the data. So Querying books details can be fast and searching will take less time.
It can also be pointed out that it wont be too expensive for Hardware implemtation as HashTables stores data based on Hash Functions and memory consumption is also optimal which reduces memory wastages.
Answer:
Following are the program in the Python Programming Language.
#get input from the user length of the pizza
inputStr = input('Enter the length of pizza: ')
#convert input into float
L = float(inputStr)
#initialize the area of the pizza
A = L*L
#calculate the amount of peoples can eat pizza
men = int(A/100)
#print the number of peoples
print('\nPizza can be eaten by {} people'.format(men))
<u>Output</u>:
Enter the length of pizza: 20
Pizza can be eaten by 4 people
Explanation:
<u>Following are the description of the program</u>.
- Firstly, set a variable that get length input from the user.
- Set variable 'L' that convert the input from the user into the float data type.
- Set variable 'A' that stores the area of the pizza.
- Set variable 'men' that store the amount of peoples can eat pizza.
- Finally, print the number of peoples can eat pizza.
Answer:
INSERT INTO Movie(Title,Rating,ReleaseDate)
VALUES("Raiders of the Lost ArkPG",'PG',DATE '1981-06-15'),
("The Godfaher",'R',DATE '1972-03-24'),
("The Pursuit of Happyness",'PG-13',DATE '2006-12-15');
Explanation:
The SQL statement uses the "INSERT" clause to added data to the movie table. It uses the single insert statement to add multiple movies by separating the movies in a comma and their details in parenthesis.