All Topics
Total 23 results

Data Structure

Write an algorithm for Merge Sort.

Merge Sort is a divide-and-conquer algorithm that divides the input list into two halves, recursively sorts each half, and then merges the two sorted halves back together. It is an efficient, stable, and comparison-based sorting algorithm with a time complexity of O(n log n) in all cases (best, aver ...

Data Structure

Compare and contrast Depth First Search (DFS) and Breadth First Search (BFS) in terms of their algorithms, uses, and performance.

Depth First Search (DFS) and Breadth First Search (BFS) are two fundamental graph traversal algorithms used in many areas of computer science, such as artificial intelligence, networks, and pathfinding. While both explore nodes in a graph or tree, they do so using different strategies and data struc ...

Web Programming

Write PHP code to interact with MySQL ( insert, select, and display data).

In PHP, we can interact with a MySQL database to store, retrieve, and manage data. This is done through SQL (Structured Query Language) queries, which can be executed from PHP scripts using the MySQLi extension or PDO (PHP Data Objects). In this example, we will focus on using MySQLi. Steps to inter ...

Web Programming

What is the difference between GET and POST methods in PHP?

Lets talk about the GET and POST methods in PHP. These are two types of HTTP request methods used to send data from a client (like a web browser) to a server. When you fill out a form on a website, for example, the data you enter needs to be sent to the server, and we can do that using either the GE ...

Data Structure

What is Sparse Matrix.

A sparse matrix is a matrix that has a lot of zeros in it. In other words, most of the elements in a sparse matrix are zeros, and only a small number of elements actually contain useful values. For example, imagine a 100x100 matrix. If only a few of the cells have values, and the rest are all zero, ...

Data Structure

Write an algorithm for Bubble sort

Bubble Sort algorithm, which is one of the simplest sorting algorithms. Sorting means arranging a list of items in a particular order, such as ascending or descending order. Bubble Sort is a method to sort a list of numbers or elements in an increasing order. <strong>Bubble Sort Algorithm</strong> ...

Data Structure

Sort numbers using insertion sort. Show all passes.

Insertion Sort, which is a simple sorting algorithm. Imagine you're organising a row of books on a shelf. You start with one book, and then, for each new book, you find the right position for it by comparing it with the books you've already placed. This process is what we call insertion sort. <stro ...

Data Structure

Translate infix expression into its equivalent postfix expression

An infix expression is a mathematical notation where operators appear between operands (e.g., A + B). A postfix expression places operators after operands (e.g., A B +). <strong>Steps for Infix to Postfix Conversion:</strong> 1. Use a stack to store operators and parentheses while processing the ex ...

Data Structure

Write a program to implement a Circular Queue and show how it differs from a normal queue.

A queue is a linear data structure that follows the FIFO (First In, First Out) principle. Think of it like a line of people waiting at a ticket counter: the person who arrives first is served first. However, a normal queue has a limitation—when elements are removed from the front, the space is not r ...

Data Structure

Explain Row Major and Column Major with Example

● Row Major Order: Think of searching row by row. You start at the very top left corner and read across the entire first row. Then, you move down to the second row and read across again. You keep going down, row by row, until you find the treasure (or the specific number you're looking for). ● Colu ...

Data Structure

Derive basic operation of stack and write C function to implement it

A stack is a type of data structure that follows a very simple principle called LIFO—Last In, First Out. Imagine a stack of plates in your kitchen. You always place new plates on top, and when you need one, you take the plate from the top of the stack. So, the last plate you put on is the first one ...

Data Structure

Differentiate Primitive and Non Primitive Data Structures

These are the most basic types of data structures, the "building blocks" of all other types of data. They hold only one value at a time. Think of them as the most basic, fundamental types of data we can store in a computer. <table style="width: 100%; border-collapse: collapse; margin: 0 auto;"> ...

Data Structure

Explain Tower of Hanoi with suitable example.

Tower of Hanoi, which is a classic problem in computer science and mathematics. The Tower of Hanoi involves three rods and a number of disks of different sizes. The goal is to move all the disks from one rod to another, but there are a few rules we need to follow <strong>Tower of Hanoi</strong> The ...

Data Structure

Define hash function. Explain it with suitable example.

A hash function is a function that takes an input (or "message") of any size and maps it to a fixed-size value, which is typically a number. The result of this mapping is called a hash value or hash code. Hash functions are commonly used in data structures such as hash tables to quickly locate data ...

Data Structure

Define time and space complexity. Derive time complexity of merge sort.

Time complexity refers to the amount of time an algorithm takes to run as a function of the size of the input. Essentially, it tells us how the running time of an algorithm increases as the input size increases. We typically express time complexity using Big-O notation, which simplifies the analysis ...

Data Structure

Explain data structure. Enlist and explain the importance of data structure.

In computer science, a data structure is a way to store and organize data in a computer so that we can use it efficiently. Think of it like a container where we keep different types of data, like numbers, words, or even more complex things like lists or images. How we store the data depends on how w ...

Web Programming

Explain frameset and frame tag with proper example.

What is a &lt;frameset>? Imagine you have a big page, and you want to divide it into smaller sections. Instead of loading everything on one page, you can split it into several parts, each showing different content. The &lt;frameset> tag helps you achieve this by dividing your web page into rows or c ...

Programming for Problem Solving

Construct a C program to check if entered integer is a prime number or not

<h2>Notes:</h2> To construct a C program that checks whether a given integer is a prime number or not, follow the steps outlined below. We will use a simple method where we check if the number is divisible by any number from 2 to the square root of the given number. Step-by-Step Explanation: 1. Un ...

Web Programming

What is cascading style sheet, Compare inline, embedded and external style sheet with example.

Okay, let's break this down step-by-step. We’re going to discuss Cascading Style Sheets (CSS), which is a fundamental part of web design. CSS controls how web pages look by defining the style of elements on a webpage, such as text, images, and layout. There are mainly three types of css Inline Css, ...

Programming for Problem Solving

Construct a C program which receives number of days as input and converts them in to Year, Months and Days.

The C programming language is a general-purpose, operating system-agnostic, and procedural language that supports structured programming and provides low-level access to the system memory. Dennis Ritchie invented C language in 1972 at AT&T (then called Bell Laboratory), where it was implemented in t ...

Data Structure

Explain bubble sort with suitable example.

Sorting simply means arranging a collection of items (numbers, words, etc.) in a particular order, either ascending (from smallest to largest) or descending (from largest to smallest). For example, when you organize your books from the smallest to the largest, you’re sorting them. Now, how does ...

Programming for Problem Solving

Illustrate the basic structure of a C Programs and highlight usual sections of main function.

A C program is a set of instructions that tells the computer what to do. At the heart of every C program, there is a function called main(). This function is important because it's the starting point of any C program. When you run a C program, the execution begins from the main() function, and it en ...

Programming for Problem Solving

Define Flow chart, List the rules for designing a Flow chart and Rephrase the merits and demerits of flow chart.

A flow chart is a diagram used to represent a process or algorithm. It uses symbols like ovals, rectangles, diamonds, and arrows to visually show the sequence of steps in a process. Flow charts are particularly useful in programming to visualize the logic of an algorithm before it is implemented in ...