Frieds, please find my 2 books (wip) https://lnkd.in/dG9CJPNE and https://lnkd.in/dMm_9Hqk
about Data Structures and Algorithms and Quantum Computing, Please help me with suggestions.
Shridhar Venkat's Blog
Thursday, July 9, 2026
My Impression of AI Tools
I have tried the following AI tools: ChatGPT, Claude, and Visual Studio CoPilot.
These tools are pretty impressive.
I asked ChatGPT to answer some general questions and produce some code such as some of my favourite algorithms. With Claude (free), I tried creating a Django project, a MERN project, asking about Smt. Indira Gandhi Ji, asking about Ravi Shastri, and I also asked for a PPTX on Cloud Computing with 20 slides. With Visual Studio CoPilot, I asked for a few standard algorithms for C++ console application.
All the answers were almost perfect. However, sometimes, I needed to tweak the result of the AI. We do not have complete control on what the AI generates. May be, the prompt must be more specific to get the best results. The projects and algorithms took almost no time.
I am not a soldier. But, if I were, AI is like better guns. But, that does not mean the soldier can afford to be weak. He must be physically fit and know what is war. The programmer is still required. He must be able to verify and modify the generated code. Only, the productivity has been increased.
Wednesday, April 16, 2025
Tuesday, January 21, 2025
Notes on Quantum Computing
Hello All, I am trying to compile some introductory notes on quantum computing. Please let me know if you find any mistakes in it.
https://drive.google.com/file/d/1RglfCx5vU5-2XCIwEew3nfA0ITmYdsmz/view?usp=sharing
Thursday, October 22, 2020
An experiment using Node.js
An experiment with Node.js
Javascript is a scripting language originally used for bringing interactivity to web-pages. Javascript executes within an engine completely on the client side within a browser. Javascript is embedded in an HTML code and has access to the HTML elements. It can be used to respond to HTML buttons, validate forms, draw on canvas etc...
Now, Javascript engine (Google's version) has been embedded within a C++ program so that Javascript can be used as a console program. This is called Node.js. Among other things, Node.js can be used to implement an http server. Node has many libraries provided by built-in modules such as file, os, events and http. By default, calls are asynchrononous with Node using a single thread. This makes Node very efficient. Events allow to code asynchronous events with publish/subscribe model.
A simple RESTful server can be implemented using Node by looking at the http request method and the http request url. The response can contain client side Javascript code. The following is a simple experiement with Javascript on both server and client:
-----------------------------------------------------------------
app.js (Run as: node app.js)
-----------------------------------------------------------------
const mod1 = require('./MOD1');
const http = require('http');
const fs = require('fs');
mod1.log('FACT of 5 is ' + mod1.fact(5));
http.createServer((req, res)=>{
if (req.url == "/PPP") {
res.write("<BODY style='color:red;'>");
res.write(req.url);
fs.readFile('a.txt', (err, data)=>{
res.write(data);
res.write("<form method='post' action='http://localhost:3000/QQQ'><input type='submit'/></form>");
res.write("</BODY>");
res.end();
});
} else {
res.write("<BODY style='background-color:red;'>");
res.write(req.url);
fs.readFile('b.txt', (err, data)=>{
res.write(data);
res.write("<form method='post' action='http://localhost:3000/PPP'><input type='submit'/></form>");
res.write("</BODY>");
res.end();
});
}
}).listen(3000);
-----------------------------------------------------------------
Node allows user-defined modules such as MOD1.js:
-----------------------------------------------------------------
function log(message) {
console.log(message);
}
function fact(n) {
if (n <= 1) {
return 1;
}
return n*fact(n-1);
}
exports.log = log;
exports.fact = fact;
-----------------------------------------------------------------
a.txt:
-----------------------------------------------------------------
<H1 style="color:blue;">
THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG!
</H1>
<canvas id="myCanvas" width="200" height="100"
style="border:1px solid #c3c3c3;">
Your browser does not support the canvas element.
</canvas>
<script>
function draw() {
alert('a');
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(0,0,150,75);
}
function clean() {
alert('b');
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "#FFFFFF";
ctx.fillRect(0,0,150,75);
}
</script>
<button onClick="draw();">DRAW</button><br/>
<button onClick="clean();">CLEAR</button><br/>
-----------------------------------------------------------------
b.txt:
----------------------------------------------------------------
A STITCH IN TIME SAVES NINE.
Sunday, August 16, 2020
Some Programming Questions
Some Programming Questions
I was encouraged to write this blog by my friend Vinay Dabholkar. I thank him very much. I hope you find it useful.
I have “served” in the Indian IT Industry for about 14 years. I have conducted entry-level interviews. I have also been a faculty member at a private University at Bengaluru for a semester.
The most important skill I look for is “coding”, i.e., the ability to write a computer program.
One of my most favourite questions is write a method to find the minimum in an array. Many students will write the “main” method with print statements. Many will hard code an array. Many will make the mistake of sorting the array. If you got the method right, I will ask if the array can be empty and have you taken care of it.
Apart from coding, other questions include RDBMS and SQL. Nowadays students are expected to know a lot of current trending topics such as Data Structures and Algorithms, Data Science, Machine Learning and IoT.
I am listing below a few questions/problems. Most of them can be answered using a language like Java or C++. Handle all kinds of situations that can occur. Write the most efficient code,
Write a method which finds the sum of an integer array.
Write a method which finds the average of an integer array.
Consider the statement: double d = 1/2;
What is the value of d?
Consider the method:
int m(int x) {
x = x / 2;
}
… // main program
m(y);
…
What is the value of y after m is called?
Consider the method:
int m(int x) {
x = x / 2;
x++;
x++;
x++;
x = x++;
return --x;
}
… // main program
int y = m(7);
…
What is the value of y after m is called?
Write an efficient method which checks whether a given array contains a certain element. How will you do this using templates in C++ or generics in Java?
Write an efficient method which counts the occurrences in a given array of a certain element. How will you do this using templates in C++ or generics in Java?
Is it always possible to do binary search on an array? Write code for binary search.
Write a method that merges two sorted arrays into a single sorted array.
What is a stable sorting algorithm? Give examples of stable and unstable sorting algorithms.
What is the most efficient way of finding the middle-valued element of an array of numbers?
How can I find the minimum and maximum values in an array of numbers using the least number of comparisons?
What is the best way to represent a set? What are the times for set operations?
Write a class that implements a queue without using arrays or ready-made collections or STL classes.
Write a class that implements a stack without using arrays or ready-made collections or STL classes.
What is an abstract data type?
Write an interface for stack.
Write an interface for queue.
What are the ways of representing a directed graph?
Write a method to check if a directed graph has a cycle.
Write a method to check if a node can be reached from another in a directed graph.
Write a method to find the 3rd smallest element in an array.
Write a method to find the kth smallest element in an array.
Describe a data structure for storing words of a dictionary. It should be possible to search for any word in O(n) time where n is the word’s length. Write the search method,
What is a hash table? What is the difference between separate chaining and probing?
Write methods for insert and delete for a queue using a circular linked list. How is a circular linked list better than a simple linked list?
List applications of stacks.
List applications of queues.
List applications of heaps.
What are AVL trees? What are their advantages?
Write a method to reverse an array.
Write a method to find a given element in a sorted array efficiently.
Write a method that takes in two linked lists and joins them efficiently.
Write a method that will sort an array of size n in ascending order using O(1) extra space with a guarantee of O(n log n) worst case time.
Two linked lists of sizes m and n are the same beyond a common node. Write the most efficient code for finding the first common node. What is the time complexity?
Write a method to compute factorial of n which is efficient in time and space.
Write a class for a binary search tree with insert, delete and search methods.
Write a class for a general tree with insert, delete and search methods.
Write a method for in-order traversal of a binary tree.
Write a method which reads a string containing digits and operators +, -, *, / and evaluates it.
There is an array with positive and negative numbers.
Write a method to find a contiguous part of the array with the maximum sum.
Write an efficient method returning the Fibonacci of n.
Write an efficient method to multiply two matrices.
Write a method to find the least costs of travelling by air from Mumbai to all cities in India assuming fixed fares.
Determine the Merge Point of 2 Linked Lists
Find distinct elements common to all rows in a Matrix
Determine the Least Common Ancestor in a Binary Search Tree
Print the maximum square sub matrix of given size
Maximum size rectangle binary sub-matrix with all 1s
Palindrome Partitioning
Determine common elements in all rows of a given Matrix
Return the kth smallest element from an array of integers
Construct the Binary Search Tree given the Pre-order traversal
Merge 2 sorted arrays
Merge 2 sorted linked list such that the merged list is in descending order
Given a Circular Linked list find the element at 1st position after n shifts.
Given an array of numbers sorted in ascending order and a key, find the value in the array closest to the key.
Given a string of characters, find the length of the longest substring which is a palindrome.
Given a bag of limited weight capacity and a number of items each with a cost and weight, find how the bag can be filled to maximize the cost of the bag.
Case 1: Assume that an item can be picked up even partially,
Case 2” Assume that an item is either picked up or not picked up.
Given n-letter sequences of characters, we say a sequence is directly related to another if the former can be converted to the latter by changing only one character. Given a set of n-letter sequences, find if a sequence s can be connected to another d either directly or indirectly.
Given a set of points in a plane, find the least distance between any two points.
Assume there are n people who are on a road at different positions. There are n houses aat different locations along the road. How will you assign the houses the people so that the overall time taken for them to reach their houses is minimized?
Given two strings, find the length of the longest common subsequence.
Given a linked list, write a method to reverse it without creating any new node.
How will you cut a rope of length n into smaller parts of integral length so that the product of the lengths is maximized?
Given binary trees t and s, check if s is a subtree of t.
Given a piece of gold weighing m grams, break it into smaller pieces each of integral number of grams so that the net price is maximized. You have different prices for different weights.
Given a linked list, delete all occurrences with a given kay.
Given a binary tree containing values, check if it is a binary search tree.
Given a binary tree and a key, find the lowest level where the key occurs.
Given a sequence of cells each with a number of 1 Rupee coins, find the maximum money that can be had if I am allowed to pick up coins from a cell only if I am not picking up from a cell to its right and from the 2 immediate cells to its right.
Given a graph with units on the x axis starting from 0 and going till n, and different height on the y axis, find the maximum area rectangle that can fit in it.
Given a matrix, find the maximum sum subarray.
Given a matrix, find the maximum area of a rectangle with all zeros.
Trial Cars Problem.
Four Queens Problem: Given a 4 x 4 chess board, arrange 4 queens on it so that all the queens are safe from each other.
What is the best way to multiply two n-degree polynomials?
Activity Selection: Given n activities with positive integral start and end times, find the maximum number of activities that can be done if only one activity can be done at a time.
Job Sequencing: Given n jobs each with a positive integer deadline and a profit that can be gained if it is completed before the deadline, find the maximum profit, if only one job can be done at a time.
Shelves Fitting.
Egyptian Fraction: Given any fraction less than 1 in the form n/d, express it as a sum of fractions of the form 1/b where each b is unique. For example, 2/3 = ½ + 1/6.
Maximum Subarray Product: Given an array of integers (positive and negative), find the maximum product of any subarray.
Minimum Subarray Product: Given an array of integers (positive and negative), find the minimum product of any subarray.
Given an undirected graph and an integer m > 0, write a method to check if the vertices can be colored using m different colors so that no two adjacent vertices are of the same color.
Implement a stack using queues.
Implement a queue using stacks.
Search for a key in a sorted array.
Implement a stack with an additional operation which gets the minimum value in the stack efficiently with/without using an auxiliary stack.
Find the third largest element in an array.
Find the fourth largest element in a linked list.
Check if a binary tree is full, perfect or complete.
Check if a string of opening and closing parentheses is balanced.
How many reversals of “(“ and “)” are needed to make a string of parenthesis balanced?
Reverse a string.
Reverse every word in a string.
Word fitting with maximum profit.
Word processing with minimum cost.
Determine if a directed graph has cycles.
Topological sort in directed graph.
Evaluate a postfix expression.
Evaluate an infix expression containing integers +, -, *, ., { and ).
Convert from infix to postfix.
Sort a linked list in O(1) space.
Interleave 2 linked lists in O(1) space.
Delete all occurrences of a value from a liked list.
Delete all occurrences of a value from a doubly liked list.
Check if a linked list has a value.
Get least level of a key in a binary search tree.
Get n th number in sequence of multiples of 5 and 7.
Get LCM of two integers.