Answer: I believe the answer is 6
Explanation: taking 35 and 65 out leaves the rest of the numbers; 15,25,45,55, and 75.
Answer:
22
Explanation:
1. We are going to have at hand 32 Enqueue Operation, with 10 from front and 15 dequeue and 5 empty queue operation
2. You dequeued total number of 15-5 =10 elements since 5 dequeue did not change the state of the queue, so invariably 10 dequeue is done.
3. Next is to enqueued a total of 32 elements.
Enqueue Operation do not change the state(and Size) of the queue, and can be ignored.
4. To arrive at the Total Size of queue, we will have 32-10 = 22 at the end
Answer : 22 because its a 5 dequeue Operations.
Answer:
The advantage of returning a structure type from a function when compared to returning a fundamental type is that
e. a and b only.
Explanation:
One advantage of returning a structure type from a function vis-a-vis returning a fundamental type is that the function can return multiple values. The second advantage is that the function can return can an object. This implies that a function in a structure type can be passed from one function to another.
Answer:
#include <iostream>
using namespace std;
void swap(int *a,int *b){ //function to interchange values of 2 variables
int temp=*a;
*a=*b;
*b=temp;
}
void sort(int queue[],int n)
{
int i,j;
for(i=0;i<n;i++) //to implement bubble sort
{
for(j=0;j<n-i-1;j++)
{
if(queue[j]>queue[j+1])
swap(queue[j],queue[j+1]); //to swap values of these 2 variables
}
}
}
int main()
{
int queue[]={6,4,2,9,5,1};
int n=sizeof(queue)/4; //to find length of array
sort(queue,n);
for(int i=0;i<n;i++)
cout<<queue[i]<<" ";
return 0;
}
OUTPUT :
1 2 4 5 6 9
Explanation:
In the above code, Queue is implemented using an array and then passed to a function sort, so that the queue can be sorted in ascending order. In the sort function, in each pass 2 adjacent values are compared and if lower index value is greater than the higher one they are swapped using a swap function that is created to interchange the values of 2 variables.