You are on page 1of 7

1. A.

Push Operation: Push operation refers to inserting an element in the


stack. Since there’s only one position at which the new element can be
inserted — Top of the stack, the new element is inserted at the top of the
stack.

B. Pop Operation: Pop operation refers to the removal of an element.


Again, since we only have access to the element at the top of the stack,
there’s only one element that we can remove. We just remove the top of
the stack.

C. isEmpty: To prevent performing operations on an empty stack,


the programmer is required to internally maintain the size of the
stack which will be updated during push and pop operations
accordingly. isEmpty() conventionally returns a boolean value:
True if size is 0, else False.

2. a) Overlooking some key features because they cannot be


prototyped affects the prototype testing

b) End-user confusion, customers mistaking it for the finished


project/developer misunderstanding of user objectives

3. Efficiency:
The software should not make wasteful use of system resources
such as memory and processor cycles.

Maintainability:
It should be possible to evolve the software to meet the changing
requirements of customers.

Functionality: The software system should exhibit the proper


functionality, i.e. it should perform all the functions it is supposed to
perform.
4. Selection sort is a simple sorting algorithm. This sorting algorithm
is an in-place comparison-based algorithm in which the list is
divided into two parts, the sorted part at the left end and the
unsorted part at the right end. Initially, the sorted part is empty and
the unsorted part is the entire list.

The smallest element is selected from the unsorted array and


swapped with the leftmost element, and that element becomes a
part of the sorted array. This process continues moving unsorted
array boundary by one element to the right.

5. a) Security breach
b) Bugs in the software

6.
7. void swap(int *xp, int *yp)

int temp = *xp;

*xp = *yp;

*yp = temp;

void selectionSort(int arr[], int n)

int i, j, min_idx;
// One by one move boundary of unsorted subarray

for (i = 0; i < n-1; i++)

// Find the minimum element in unsorted array

min_idx = i;

for (j = i+1; j < n; j++)

if (arr[j] < arr[min_idx])

min_idx = j;

// Swap the found minimum element with the first element

if(min_idx != i)
swap(&arr[min_idx], &arr[i]);

/* Function to print an array */

void printArray(int arr[], int size)

int i;

for (i=0; i < size; i++)

printf("%d ", arr[i]);

printf("\n");

}
// Driver program to test above functions

int main()

int arr[] = {3, 12, 9, 10, 5, 4};

int n = sizeof(arr)/sizeof(arr[0]);

selectionSort(arr, n);

printf("Sorted array: \n");

printArray(arr, n);

return 0;

You might also like