Implement Selection Sort in C++

Ravi Ranjan
Updated on 17-Apr-2025 16:53:03

22K+ Views

The selection sort is an in-place comparison-based simple sorting algorithm. In the selection sort technique, the list is divided into two parts: sorted and unsorted. The minimum element from the unsorted part is selected and swapped with the element at the beginning of the list. Similarly, the next minimum value from the unsorted list is placed at the next position in the sorted list, and this keeps repeating until the whole array is sorted. In this article, we have an unsorted array. Our task is to sort this array using selection sort in C++. Here is an example of selection ... Read More

Call Python File from Within PHP

SaiKrishna Tavva
Updated on 17-Apr-2025 16:49:51

11K+ Views

In PHP, we can execute Python scripts using built-in functions such as shell_exec(), exec() or popen() by enabling seamless integration between the two languages. Below are three methods to run a Python script from PHP with examples and explanations of each - Using 'shell_exec()' function One way to execute a Python script is by using the shell_exec function. This function runs a command via the shell and returns the output as a string. This function ensures that the command is safe to run by escaping any characters that could be harmful. The output of this script is sent back to ... Read More

Declare a Multi-Dimensional Dictionary in Python

Niharika Aitam
Updated on 17-Apr-2025 16:45:32

1K+ Views

Multidimensional Dictionaries in python Multidimensional dictionaries are part of the dictionaries in Python, which are used to store data. Created by assigning a dictionary to a key within another dictionary, these structures are represented by curly braces {} and can accommodate any data type. Their mutable nature allows modifications after creation. They are composed of unique key-value pairs, separated by a colon (:). While keys are unique, values can be duplicated. Accessing values requires using keys, as dictionaries do not support indexing. To retrieve specific key values, use the key combined with indexing. Syntax The following is the syntax for ... Read More

Create an Empty List in Python

Akshitha Mote
Updated on 17-Apr-2025 16:42:25

753 Views

In Python, list is one of the built-in data types. A Python list is a sequence of items separated by commas, enclosed in square brackets [ ]. The items in a Python list need not be of the same data type.  In this article, we will discuss different ways to create an empty list in Python. Using Square Brackets This is one of the simplest way to create an empty list to using square brackets[]. An empty list means the list has no elements at the time of creation, but we can add items to it later when needed. my_list=[] ... Read More

Create Python Dictionary from List of Keys and Values

Akshitha Mote
Updated on 17-Apr-2025 16:41:25

24K+ Views

In Python, the dictionary is one of the built-in data types that stores the data in the form of key-value pairs. The pair of key-value is separated by a comma and enclosed within curly braces {}. The key and value within each pair are separated by a colon (:). Each key in a dictionary is unique and maps to a value. It is an unordered, mutable data. Creating dictionary from lists In Python, we can create a dictionary by using two separate lists. One list is considered as the keys, and the second one is considered as values. We ... Read More

C Program to Find Subarray with Sum Equal to 0

C
AYUSH MISHRA
Updated on 17-Apr-2025 15:42:28

325 Views

What is a Subarray? A subarray is a contiguous part of the array. The sum of elements in a subarray is the cumulative sum of elements of a subarray. For example: in the given array [1, 2, 3, 4, 5, 6] the subarray is [3, 4, 5]. In this article, we are given an array and need to find if any subarray has a sum equal to zero using C. Example 1 Input: arr[] = {4, 2, -3, 1} Output: Yes Explanation: The subarray {2, -3, 1} has a sum equal to 0. Example 2 ... Read More

Rotate Matrix by 90 Degrees in C

C
AYUSH MISHRA
Updated on 17-Apr-2025 13:29:28

3K+ Views

In this article, we are given an N x N matrix, and our task is to rotate it by 90 degrees clockwise in C. Example Input: [1 2 3], [4 5 6], [7 8 9] Output: [7 4 1], [8 5 2], [9 6 3] Below are different approaches to rotate a matrix by 90 degrees in the clockwise direction: Using Brute Force Approach Using In-Place Rotation Using Brute Force Approach This is the simple and direct approach to understand and implement. In this approach, we create a ... Read More

Difference Between Google Gemini 2.5 and ChatGPT-4

Peehu Sharma
Updated on 17-Apr-2025 12:32:31

242 Views

Gemini 2.5 and ChatGPT 4o are both advanced AI language models. Gemini 2.5 is developed by Google DeepMind and ChatGPT, developed by OpenAI. The difference between Gemini 2.5 and ChatGPT is that Gemini 2.5 handles complex reasoning and has multimodal capabilities, also can generate text, images, and more. ChatGPT is used to generate creative content. It supports coding, writing assistance, and detailed explanations across various topics. In this article, learn the difference between Gemini 2.5 and ChatGPT in detail. What is Gemini 2.5? Gemini 2.5 is the latest version of Google's AI model and part of the Gemini AI series ... Read More

Difference Between Joomla and Tumblr

Peehu Sharma
Updated on 17-Apr-2025 12:04:06

78 Views

Joomla is a Content Management System (CMS) platform, whereas Tumblr is a microblogging platform focused on sharing short-form content like text, images, and videos in a visually appealing and social manner. This article will highlight the differences between Joomla and Tumblr. But before discussing the differences, let us first examine their basics. What is Joomla?Joomla is an open-source software used to build websites and online applications. It provides a user-friendly interface that allows users to manage content without coding knowledge. Features of Joomla Easy to Customize ... Read More

Represent Python Tuple in JSON Format

Sindhura Repala
Updated on 17-Apr-2025 11:23:57

27K+ Views

In this article, we will demonstrate how to represent a tuple in Python using JSON format. We will explore the following methods throughout the article: Converting Python Tuple to JSON Converting Python Tuple with Different Datatypes to JSON String Parsing JSON string and accessing elements using json.loads() method. ... Read More

Advertisements