Arunav Ray ISC Computer Project
Arunav Ray ISC Computer Project
QUESTION
Write a program to accept a time string in the 12-hour clock format (HH:MM AM/PM) and convert it to the
international standard 24-hour clock format (HH:MM).
Example: If input time = "09:35 PM", then the output will be "21:35".
ALGORITHM
STEP 1: Start the application execution.
STEP 2: Accept a string representing time in the format HH:MM AM/PM from the user.
STEP 3: Extract hours, minutes, and the period marker (AM/PM) using substring slicing or string tokenization.
STEP 4: Convert the extracted hours and minutes substrings into integers.
STEP 5: Check the period marker: If the marker is "PM" and hours is not 12, add 12 to hours. If the marker is "AM" and
hours is 12, reset hours to 0.
STEP 6: Format the transformed integers back into a two-digit zero-padded string format (HH:MM).
STEP 7: Output the resultant 24-hour formatted time string.
STEP 8: End the execution.
import [Link];
try {
// Extract the AM/PM part
String period = [Link]([Link]() - 2);
// Extract time components
String timePart = [Link](0, [Link]() - 2).trim();
String[] parts = [Link](":");
int hh = [Link](parts[0]);
int mm = [Link](parts[1]);
VARIABLE DESCRIPTION
2 period String main() Extracts and holds the "AM" or "PM" identifier.
3 timePart String main() Contains the time digits without the period suffix.
OUTPUT
QUESTION
Write a program to accept a specific month and year from the user and display its corresponding monthly calendar
layout in a classic grid format.
ALGORITHM
STEP 1: Start the execution.
STEP 2: Read the target integer values for Month and Year.
STEP 3: Compute the starting day of the week for the 1st day of the given month using Zeller's Congruence or Gregorian
calendar rules.
STEP 4: Define an array mapping the total days per month, incorporating a leap year calculation check for February.
STEP 5: Print the calendar headers (Sun, Mon, Tue, Wed, Thu, Fri, Sat).
STEP 6: Print the corresponding leading spacing shifts up to the calculated starting weekday.
STEP 7: Run a loop tracking days 1 through the maximum month days count, printing each day and inserting line-breaks
whenever a 7-day row sequence fills up.
STEP 8: End execution.
import [Link];
int[] days = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if (isLeapYear(y)) days[2] = 29;
[Link]("
SUN MON TUE WED THU FRI SAT");
// Print leading empty spaces
for (int i = 0; i < startDay; i++) {
[Link](" ");
}
VARIABLE DESCRIPTION
1 m/y int main() Holds the target values of Month and Year.
2 days int[] main() Array tracking the maximum total days per month element.
3 startDay int main() Calculated baseline weekday pointer for the 1st of that month.
OUTPUT
QUESTION
Write a program to implement the classical Binary Search Algorithm recursively over an ordered data array.
ALGORITHM
STEP 1: Start execution.
STEP 2: Define a search method taking an array context, lower bounds index, upper bounds index, and search target
value.
STEP 3: Base condition: If lower index exceeds upper index, target cannot be found; return -1.
STEP 4: Compute the element midpoint pointer: mid = lower + (upper - lower) / 2.
STEP 5: Match condition: If array[mid] matches the target value, return index position mid.
STEP 6: High condition: If array[mid] exceeds the target, execute recursion on the left subarray partition.
STEP 7: Low condition: Otherwise, run recursive execution on the right subarray partition.
STEP 8: Return final output results value and terminate.
import [Link];
if (arr[mid] == target) {
return mid; // Target matched successfully
}
if (matchIdx != -1) {
[Link]("Element successfully located at zero-index: " + matchIdx);
} else {
[Link]("Element not present in the given dataset.");
}
}
}
VARIABLE DESCRIPTION
2 low / high int binarySearch() Boundary tracking markers for search frames.
4 matchIdx int main() Captures tracking index value from search engine execution.
OUTPUT
QUESTION
Write a program to categorize a positive integer as an Increasing Number (each digit is greater than or equal to
the preceding digit), a Decreasing Number (each digit is smaller than or equal to the preceding digit), or a
Bouncy Number (neither purely increasing nor decreasing).
ALGORITHM
STEP 1: Start execution.
STEP 2: Accept an integer value from the user console.
STEP 3: Convert the integer into a character or string buffer format to iterate over the digits sequentially.
STEP 4: Maintain boolean tracking flags: `isInc = true` and `isDec = true`.
STEP 5: Iterate through individual consecutive pairs of digits from left to right.
STEP 6: If any left digit is greater than its right digit pair, set `isInc = false`. If any left digit is smaller than its right pair,
set `isDec = false`.
STEP 7: Analyze outcomes: If `isInc` is true, display 'Increasing'. If `isDec` is true, display 'Decreasing'. If both are false,
display 'Bouncy Number'.
STEP 8: Terminate application process.
import [Link];
String s = [Link](num);
boolean isInc = true;
boolean isDec = true;
VARIABLE DESCRIPTION
OUTPUT
QUESTION
Write a program to read a square matrix configuration and display both its 90-degree Clockwise and 90-degree
Anti-Clockwise rotated configurations.
ALGORITHM
STEP 1: Start execution.
STEP 2: Accept the square array order size input constraints matrix dimension N.
STEP 3: Populate the target two-dimensional matrix array layout block frame with integer parameters.
STEP 4: To compute 90-degree Clockwise rotation, map the source element matrix at index `(row, col)` into the
destination matrix index `(col, N - 1 - row)`.
STEP 5: To compute 90-degree Anti-Clockwise rotation, map the source element matrix at index `(row, col)` into the
destination matrix index `(N - 1 - col, row)`.
STEP 6: Iterate and output both generated temporary arrays.
STEP 7: End operational execution.
import [Link];
VARIABLE DESCRIPTION
Sl
Name Type Method Description
No.
OUTPUT
QUESTION
Write a program to generate and display a matrix of size N x N filled with sequential integers running inward in a
spiral sequence path.
ALGORITHM
STEP 1: Start execution.
STEP 2: Accept square dimension metrics matrix width N.
STEP 3: Initialize grid tracking indices variables: `top=0, bottom=N-1, left=0, right=N-1`. Initialize value counter = 1.
STEP 4: Execute loop while value counter remains lower than or equal to N * N.
STEP 5: Traverse from left boundary to right boundary along the top row; increment `top`.
STEP 6: Traverse from top boundary to bottom boundary down the rightmost column; decrement `right`.
STEP 7: Traverse from right boundary to left boundary along the bottom row; decrement `bottom`.
STEP 8: Traverse from bottom boundary to top boundary up the leftmost column; increment `left`.
STEP 9: Output final matrix allocation array data block and terminate.
import [Link];
int val = 1;
int top = 0, bottom = n - 1, left = 0, right = n - 1;
VARIABLE DESCRIPTION
1 spiral int[][] main() Target storage space grid matrix array frame.
OUTPUT
QUESTION
Write a program to find the saddle point of a square matrix. A saddle point is an element that is the minimum
element in its row and the maximum element in its column.
ALGORITHM
STEP 1: Start execution.
STEP 2: Accept row size order N inputs and construct a square grid array system.
STEP 3: Loop row index space frames cleanly tracker baseline sequence from 0 down to N.
STEP 4: In each row, locate the minimum elements item entry and note its target column pointer layout tracker.
STEP 5: Iterate through that specific column across all rows to verify if this element is also the maximum value item in
its column.
STEP 6: If both criteria are met, print the item coordinate value index and terminate.
STEP 7: If the loop completes with no match found, output an error string indicating no saddle point exists.
STEP 8: Terminate framework system.
import [Link];
if (isSaddle) {
[Link]("Saddle Point discovered at value: " + minRowVal + " at
positional coordinate (" + i + "," + colIdx + ")");
found = true;
break;
}
}
if (!found) [Link]("No Saddle Point layout exists within this dataset
grid.");
}
}
VARIABLE DESCRIPTION
2 minRowVal int main() Tracks the smallest value element inside a row workspace loop.
3 colIdx int main() Tracks the column location of the minimum element found.
OUTPUT
QUESTION
Write a program to validate whether a user-input square matrix is a Magic Matrix. A Magic Matrix is a square
matrix where the sums of elements in each row, each column, and both main diagonals are all equal.
ALGORITHM
STEP 1: Start execution.
STEP 2: Accept square dimension N values and populate data entries matrix array.
STEP 3: Calculate baseline reference sum tracking value target from the first row sequence components block data
entries.
STEP 4: Run iteration blocks validating total sum items for each separate tracking row entries block sequence against
target constraint sum.
STEP 5: Run iteration checking total elements items value block sum for every distinct structural column configuration
against target sum.
STEP 6: Compute primary diagonal sum values and secondary diagonal layout components sums.
STEP 7: If all computed sums match the baseline reference sum, display validation success statement. Otherwise, output
a failure message.
STEP 8: Terminate operational engine workflow.
import [Link];
VARIABLE DESCRIPTION
Sl
Name Type Method Description
No.
OUTPUT
QUESTION
Write a program to check whether a given string is a Pangramatic Lipogram. A Pangram is a sentence that uses
every letter of the English alphabet at least once. A Lipogram is a text that intentionally omits a specific letter. A
Pangramatic Lipogram is a sentence that uses exactly 25 distinct letters of the alphabet (omitting exactly one
letter).
ALGORITHM
STEP 1: Start execution.
STEP 2: Read string line sequence sentence item context blocks entries text data.
STEP 3: Convert all characters cleanly into uppercase layout targets framework profiles format tracking variables.
STEP 4: Establish alpha boolean array tracker length state map 26 entries initially false.
STEP 5: Scan target line item parameters string characters sequential indexes.
STEP 6: For any letter character found between 'A' and 'Z', compute its index (`ch - 'A'`) and set the corresponding
position in the boolean array to true.
STEP 7: Count the total number of true values in the tracking array.
STEP 8: If the count of distinct letters is exactly 25, the sentence is a Pangramatic Lipogram. Output the result and the
missing letter. Otherwise, output a negative result.
STEP 9: End execution.
import [Link];
int uniqueCount = 0;
char missingLetter = ' ';
if (uniqueCount == 25) {
[Link]("The text is a PANGRAMATIC LIPOGRAM.");
[Link]("Omitted letter token symbol is: " + missingLetter);
} else if (uniqueCount == 26) {
[Link]("The text is a Full Pangram, not a Lipogram (contains all
26 letters).");
} else {
[Link]("Not a Pangramatic Lipogram. Distinct count: " +
uniqueCount);
}
}
}
VARIABLE DESCRIPTION
1 text String main() Primary workspace tracking entry input string placeholder block.
2 present boolean[] main() Alphabet sequence status mapping evaluation flag storage tracking index.
3 uniqueCount int main() Tracks the count of unique letters found in the text string.
OUTPUT
Enter sentence string to test: The quick brown fox jumps over a lazy dog
The text is a Full Pangram, not a Lipogram (contains all 26 letters).
PROGRAM 25: WORD SORTER BY LENGTH ENGINE FRAMEWORK
QUESTION
Write a program to accept a sentence from the user and rearrange its words in ascending order of their lengths. If
two words have the same length, maintain their original relative order.
ALGORITHM
STEP 1: Start execution.
STEP 2: Read text sentence parameters data entry input contents.
STEP 3: Split the sentence into an array of words using whitespace as a delimiter.
STEP 4: Use a stable sorting algorithm (like Bubble Sort or Insertion Sort) to sort the words array based on word lengths.
STEP 5: During sorting, compare the lengths of adjacent words: `words[j].length()` vs `words[j+1].length()`. Swap if the
left word is longer than the right word.
STEP 6: Reassemble the sorted words into a single sentence string separated by single spaces.
STEP 7: Output the rearranged sentence.
STEP 8: End execution.
import [Link];
VARIABLE DESCRIPTION
1 inputStr String main() Raw input data sentence block framework container context.
2 words String[] main() Array holding individual extracted word string tokens.
3 n int main() Total word count tracking limit value variable framework.
OUTPUT
QUESTION
Write a program to implement a Stack data structure using an array, supporting the fundamental operations of
Push, Pop, and Display.
ALGORITHM
STEP 1: Start execution.
STEP 2: Define a class `ArrayStack` with member tracking parameters: an integer array `stk[]`, a capacity integer
variable `capacity`, and a top index pointer tracking variable `top` (initialized to -1).
STEP 3: Push operation: If `top` equals `capacity - 1`, display "Stack Overflow" error. Otherwise, increment `top` and
insert the element at `stk[top]`.
STEP 4: Pop operation: If `top` equals -1, display "Stack Underflow" error. Otherwise, retrieve the element at `stk[top]`,
decrement `top`, and return the removed element.
STEP 5: Display operation: If `top` equals -1, print "Stack is Empty". Otherwise, print elements from index `top` down
to 0.
STEP 6: Terminate operational scope framework tracker system block routines.
VARIABLE DESCRIPTION
1 stk int[] Class Member Array tracker container storage workspace frame block layer.
2 top int Class Member Index pointer targeting the topmost element of the stack.
3 capacity int Class Member Maximum allocated element data boundary constraint size.
OUTPUT
Pushed element: 10
Pushed element: 20
Pushed element: 30
Current Stack layout (Top downwards): 30 20 10
Popped item value tracker out: 30
Current Stack layout (Top downwards): 20 10
PROGRAM 27: LINEAR QUEUE IMPLEMENTATION DATA STRUCTURE
QUESTION
Write a program to implement a standard Linear Queue data structure using an array, supporting the fundamental
operations of Enqueue, Dequeue, and Display.
ALGORITHM
STEP 1: Start execution.
STEP 2: Define a class `SimpleQueue` with attributes: an integer array `q[]`, a `front` pointer index, a `rear` pointer
index, and a `capacity` limit. Initialize `front = 0` and `rear = -1`.
STEP 3: Enqueue operation: If `rear` equals `capacity - 1`, display "Queue Full" (Overflow). Otherwise, increment
`rear` and insert the item at `q[rear]`.
STEP 4: Dequeue operation: If `front` is greater than `rear`, display "Queue Empty" (Underflow). Otherwise, retrieve
`q[front]`, increment `front`, and return the removed item.
STEP 5: Display operation: If `front` is greater than `rear`, print "Queue Empty". Otherwise, loop and print elements
from index `front` up to index `rear`.
STEP 6: End execution.
VARIABLE DESCRIPTION
2 front int Class Member Pointer index for extracting elements from the front of the queue.
3 rear int Class Member Pointer index for inserting elements at the end of the queue.
OUTPUT
QUESTION
Write a program to implement a Double-Ended Queue (DEQUEUE) data structure using an array, supporting
insertion and deletion operations from both ends (Front and Rear).
ALGORITHM
STEP 1: Start execution.
STEP 2: Define a class `Deque` with attributes: an integer array `arr[]`, a `front` pointer index, a `rear` pointer index, and
a `size` property. Initialize `front = -1` and `rear = -1`.
STEP 3: insertFront operation: If the queue is full, print "Overflow". If the queue is initially empty, set both pointers to
0. Otherwise, decrement `front` cyclically and insert the item at `arr[front]`.
STEP 4: insertRear operation: If the queue is full, print "Overflow". If the queue is initially empty, set both pointers to
0. Otherwise, increment `rear` cyclically and insert the item at `arr[rear]`.
STEP 5: deleteFront operation: If the queue is empty, print "Underflow". If only one element remains, reset both
pointers to -1. Otherwise, retrieve the element and increment `front` cyclically.
STEP 6: deleteRear operation: If the queue is empty, print "Underflow". If only one element remains, reset both
pointers to -1. Otherwise, retrieve the element and decrement `rear` cyclically.
STEP 7: End execution.
VARIABLE DESCRIPTION
1 arr int[] Class Member Internal storage space array container block.
2 front / rear int Class Member Dynamic index boundary control pointer trackers.
3 size int Class Member Total size boundaries allocations limitation limit parameter.
OUTPUT
Inserted at Rear: 10
Inserted at Rear: 20
Inserted at Front: 5
Deleted from Rear: 20
Deleted from Front: 5
PROGRAM 29: SINGLY LINKED LIST CORE ARCHITECTURE
QUESTION
Write a program to implement a Singly Linked List dynamic data structure, supporting fundamental sequential
node operations such as Insertion at End and Traversal Display.
ALGORITHM
STEP 1: Start execution.
STEP 2: Define a helper class `Node` containing two member fields: an integer `data` and a reference pointer object
`next` pointing to the next node object instance.
STEP 3: Define a main class `SinglyLinkedList` containing a root tracking element node field reference named `head`.
STEP 4: insertNode operation: Create a new node instance containing the target integer data. If `head` is null, assign
this new node as the `head`. Otherwise, initialize a temporary traversal pointer variable to walk through the list until reaching
the last node (where `next` is null), then link the last node's `next` pointer to the new node.
STEP 5: printList operation: If `head` is null, display "List is Empty". Otherwise, loop through all nodes sequentially
using a temporary traversal pointer and print each node's `data` value until the pointer reaches null.
STEP 6: Terminate operational routine scope framework.
Node(int val) {
data = val;
next = null;
}
}
VARIABLE DESCRIPTION
1 head Node Class Member Root pointer referencing the first node instance in the list.
2 data int Node Class Data payload field of an individual node instance.
3 next Node Node Class Reference pointer link field targeting the next sequential node object.
OUTPUT
Linked List Chain Framework View: 101 -> 202 -> 303 -> NULL
PROGRAM 30: OBJECT-ORIENTED PRINCIPLES: INHERITANCE
QUESTION
Write a program to demonstrate Object-Oriented Programming (OOP) inheritance capabilities by creating a base
superclass `Record` and deriving a subclass `Compute` to track and process commercial consumer item inventory
data parameters.
ALGORITHM
STEP 1: Start execution.
STEP 2: Define a base parent class named `Record` with attributes: `String name` and `int cashAmount`. Implement a
constructor to initialize these tracking fields and a `display()` routine method to print them.
STEP 3: Create a subclass named `Compute` that extends the `Record` base class, introducing a new local member
variable field: `int operationalDays`.
STEP 4: In the `Compute` constructor, invoke the parent superclass constructor using the `super()` keyword parameter
token to initialize the inherited fields (`name` and `cashAmount`). Then, initialize the local subclass field `operationalDays`.
STEP 5: Implement a method in the `Compute` subclass to calculate the total due amount based on operational days and
cash value metrics.
STEP 6: Override or extend the `display()` method to print both the inherited base properties and the computed subclass
results.
STEP 7: Instantiate the `Compute` class in a `main()` entry method to execute and verify the inheritance pipeline.
STEP 8: End execution.
@Override
public void display() {
[Link](); // Invoke parent display routine
[Link]("Total tracked billing operational window days: " +
operationalDays);
[Link]("Calculated net total financial invoice dues balance: INR " +
totalDue);
}
}
VARIABLE DESCRIPTION
1 name String Record Class Protected string field tracking the account holder's name.
2 cashAmount int Record Class Protected field tracking base financial rate units.
3 operationalDays int Compute Class Private subclass field tracking total active transaction days.
4 totalDue double Compute Class Private field tracking the computed net financial dues balance.
OUTPUT