Found 34494 Articles for Programming

Print objects of a class in Python

Niharika Aitam
Updated on 06-Nov-2023 12:22:16

1K+ Views

An object is the part of the Object Oriented Language (OOPs), which is an instance of the class. The class is the blueprint or template that specifies the methods and properties of that given class. When we create an object of a class, it contains all the set of instance methods and variables that are related to that particular object Using __str__ method We have two methods namely, __str__ or __repr__ in python which automatically calls the string and used to print the object with the detail view about it. Following is the syntax for using the __str__ method. ... Read More

Django Form submission without Page Reload

Niharika Aitam
Updated on 06-Nov-2023 12:27:03

682 Views

In Django, we can submit the form without reloading the page using the Jquery and Ajax (Asynchronous JavaScript and XML) requests. Let’s see an example to work with the Ajax to submit the Django form without reloading the page. Create a new Django project First create a new project in Django with the name Reload_project and also create a new app in the project directory with the name Reloadapp by executing the below commands in the command prompt. django-admin startproject Reload_project cd Reload_project django-admin startapp Reloadapp Now in INCLUDED_APPS in settings.py file of the Reload_project directory, add the ... Read More

Django form field custom widgets

Niharika Aitam
Updated on 06-Nov-2023 12:34:32

92 Views

A widget is the representation of the Html input element using Django. The widget is used to handle the rendering of the HTML page and data extracting from the POST/GET dictionary. Every time whenever we specify the field on a form, Django uses the default widget to display the data in an appropriate manner. Django is the one of the best Framework used by most of the users, to perform the web development. It provides many advanced features, functions and packages to design the best web pages and connect with the servers using the python programming language. Now let’s ... Read More

Django CRUD (Create, Retrieve, Update, Delete) Function Based Views

Niharika Aitam
Updated on 06-Nov-2023 13:02:39

354 Views

CRUD is abbreviated as Create, Retrieve, Update and Delete Functions. In Django, we can perform all these CRUD operations on the data we created into the database. Now let’s create the views.py function based on the operation that we want to perform. Create Operation with Django Create is used to create or add new data entries to the database table. In the following snippet, we begin by importing both the model form and the corresponding model. Next, we proceed to check whether the request is a POST request. If it is a POST request, we create a new form ... Read More

XOR Linked List – A Memory Efficient Doubly Linked List

Divya Sahni
Updated on 03-Nov-2023 15:28:07

2K+ Views

Linked List The linked list is a linear data structure containing elements called nodes. Each node consists of two main components: data (payload of that node) and a pointer to the next node in the list. They are simple and efficient to use providing easy allocation and deallocation of memory. Doubly Linked List Doubly linked list is a special type of linked list which again consists of a basic element called nodes. Each node consists of three main components: data (payload of that node), a pointer to the previous node of the sequence and a pointer to the next ... Read More

Sort numbers stored on different machines

Divya Sahni
Updated on 03-Nov-2023 15:12:14

544 Views

In today’s world with a large amount of data and interconnected systems, a vast amount of data is created and stored across various machines. One challenging challenge is to sort this data stored across multiple devices. Sorting being a fundamental operation in computations is used for optimal retrieval, search and analysis of data. But with distributed systems and various interconnected machines, this task of sorting becomes difficult and important. Problem Statement Given an array containing N linked lists that depict N different machines. Each of these linked lists contains some variable number of numbers in sorted order. The task is ... Read More

Segment Tree | Sum of a given range

Divya Sahni
Updated on 03-Nov-2023 15:10:40

407 Views

Segment Tree A segment tree is a tree data structure used for storing intervals and segments. It is a static structure, i.e. it cannot be modified once it is built. Segment trees are used to handle range queries on an array or a similar linear data structure. In a segment tree, we divide an input array into segments and precompute the values for these segments. Each node in a segment tree depicts an interval or segment of the array. The root node represents the entire array and each child node represents the segments formed by dividing the parent node. This division leads ... Read More

Segment Tree | Range Minimum Query

Divya Sahni
Updated on 03-Nov-2023 15:06:10

516 Views

Segment Tree − A segment tree is a tree data structure used for storing intervals and segments. It is a static structure, i.e. it cannot be modified once it is built. Segment trees are used to handle range queries on an array or a similar linear data structure. In a segment tree, we divide an input array into segments and precompute the values for these segments. Each node in a segment tree depicts an interval or segment of the array. The root node represents the entire array and each child node represents the segments formed by dividing the parent node. This ... Read More

Print unique rows in a given Binary matrix

Divya Sahni
Updated on 03-Nov-2023 15:01:03

322 Views

In computer science, binary matrix holds a very strong position containing a lot of information as the data is depicted using 0’s and 1’s which is the language of computers. In binary matrix, unique row refers to a row that is not identical to any other row in the matrix. Each unique row contains unique information that is not present anywhere else in the matrix except the row itself. Discovering these unique rows give information about relationships between rows, patterns in the matrix and identification of critical elements. Problem Statement Given a binary matrix mat[] containing 0’s and 1’s. The ... Read More

Pattern Searching using Suffix Tree

Divya Sahni
Updated on 03-Nov-2023 14:57:58

349 Views

Trie − A trie is a tree-based data structure used to store and retrieve a dynamic set of strings. Compressed Trie − A compressed trie is a variation of the trie data structure used for storing and searching dynamic sets of strings. Memory usage is minimised by sharing common prefixes. In a compressed trie, nodes with only one child are merged with their parent nodes compressing the common prefixes into a single edge. Suffix Tree − A suffix tree is a data structure used in string processing to store and search for all suffixes of a given string. It represents all possible suffixes ... Read More

Advertisements