Found 34494 Articles for Programming

How to iterate LinkedHashMap in Java?

Deepti S
Updated on 19-Oct-2023 12:23:08

1K+ Views

LinkedHashMap is a class that is identical to HashMap, however it additionally provides a feature that tracks the order wherein components are inserted. The sequence wherein elements were added isn't preserved by using HashMap, even though it does permit for quick element insertion, search, and deletion. By keeping a linked list of every entry in the map, LinkedHashMap addresses this issue. The elements are saved in the sequence that they were introduced thanks to this linked list. As a result, while iterating over a LinkedHashMap, the elements are returned according to how they were added. Methods Used To iterate LinkedHashMap ... Read More

Python program to calculate acceleration, final velocity, initial velocity and time

Niharika Aitam
Updated on 19-Oct-2023 14:17:19

631 Views

Acceleration, final velocity, initial velocity and time are the terms related to physical science which are widely used to study the motion and mechanics. Let’s see each one in detail. Acceleration Acceleration is the rate at which an object changes its velocity over the given time. It is denoted by a. Mathematically it is defined as the change in velocity divided by the change in time, the following is the formula. The unit of acceleration is meters per second $\mathrm{(m/s^2)}$ $\mathrm{a \:=\:(\Delta;\:vf − \Delta;vi)/\Delta;t}$ Where, $\mathrm{\Delta\:vi}$ is the Initial velocity $\mathrm{\Delta\:vf}$ is the Final velocity $\mathrm{\Delta\:t}$ is the ... Read More

How to Iterate Through HashTable in Java?

Deepti S
Updated on 19-Oct-2023 12:20:05

1K+ Views

The HashTable is a fundamental data structure that operates on the basis of key hashcodes without preserving the insertion order. It prohibits duplicate keys but allows for duplicate values. Remarkably, it accommodates a wide range of objects for both keys and values, fostering heterogeneity. Null values for keys and values are not allowed, though, as doing so would cause a RunTimeException called a NullPointerException. The HashTable implements the serializable and cloneable interfaces in terms of interfaces, but it fails to implement the RandomAccess interface. Additionally, all the methods within the HashTable are synchronized, ensuring thread safety for HashTable objects. When ... Read More

How to Iterate LinkedList in Java?

Deepti S
Updated on 19-Oct-2023 12:16:22

94 Views

The LinkedHashMap Class is similar to HashMap. But it has an additional feature in comparison to HashMap. The LinkedList class belongs to the java.util package. A doubly linked list is how LinkedList stores its elements. Given that our operations typically include insertion and deletion, LinkedList is the best option. The java.util package contains the LinkedList collection framework. It acts as an implementation of the non-contiguous LinkedList data structure, which saves elements in memory. Methods Used There are five main methods that you can use for iterating HashMap − Using the for loop Making use of a while loop Using ... Read More

Profiling in Python

Niharika Aitam
Updated on 19-Oct-2023 14:14:53

65 Views

In Python profiling is the measure of performance of different parts of a program to check and identify the areas of optimization and bottlenecks. We have many tools to perform profiling for the python code which includes built in modules, libraries and IDEs (Integrated development environments). There are different types of profiling of the python code, let’s see them one by one. Using Line profiling Line profiling is the technique used to measure the execution time of each individual line of the program. It helps us to identify which line is taking more execution time and to identify the tight ... Read More

Profile Application using Python Flask and MySQL

Niharika Aitam
Updated on 19-Oct-2023 14:12:47

134 Views

Flask is one of the web frameworks which provide libraries to build light weight web applications in python. It is a micro framework, developed by Armin Ronacher who runs an international group of python enthusiasts (POCCO). Flask works on WSGI toolkit and jinja2 template engines. For creating the profile application using python flask and MySQL we have to follow the below mentioned steps one by one. Step − 1 Install the virtual environment by executing the below mentioned command in the command prompt. pip install virtualenv Once the virtual environment is created we can create the new virtual environment into ... Read More

ProcessPoolExecutor Class in Python

Niharika Aitam
Updated on 19-Oct-2023 14:07:03

72 Views

The ProcessPoolExecutor class in python is part of the concurrent.futures module, is a high level interface for asynchronously executing functions using the processes and threads. The ProcessPoolExecutor allows us to execute the multiple functions in parallel using the multiple processes, which is particularly useful to CPU bound tasks that benefit in the parallelization process. Multiprocessing and Multithreading Before going to see about the ProcessPoolExecutor class we have to know about the Multiprocessing and Multithreading. Multiprocessing and Multithreading are the techniques used to achieve the parallelism process and they are different in the way they manage and create concurrent tasks. Multiprocessing ... Read More

Private Methods in Python

Niharika Aitam
Updated on 19-Oct-2023 14:04:56

902 Views

In Python, we can define the private method by prefixing the single underscore to the method name and like the other programming languages we cannot prevent accessing the private method outside the class in python. Simply we can say the private method is used only internally for the defined class. What is private method and public method? A private method is the method that should be called only inside the defined class whereas the Public method is defined within the class, can be called on an instance of the defined class. Now let’s define the private method and see ... Read More

Priority Queue using Queue and Heapdict module in Python

Niharika Aitam
Updated on 19-Oct-2023 11:45:08

172 Views

The priority Queue is the abstract data type which is similar to the queue or stack, in which each element is attached with a priority. Here the priority determines the order of the elements to be dequeued from the queue and the higher priority elements are dequeued before the elements with the lower priority. The priority queues will be implemented using different data structures such as heaps, arrays or balanced trees. The most commonly used implementation is the heap, which is the binary tree based data structure having the value of each node greater than or equal to the values ... Read More

How to Iterate the Vector Elements in the Reverse Order in Java?

Deepti S
Updated on 18-Oct-2023 16:35:11

115 Views

The Vector class has been a part of the Java collection system since Java version 1.2. Vectors are sometimes known as Dynamic Arrays because, unlike ordinary arrays, they can expand and contract in size. Ensuring thread-safety, Vectors are synchronized. While there exists a third approach that involves using Apache Commons to iterate through the vector in reverse, this method necessitates the downloading of additional jar files and packages, which is not widely supported by most systems. Essentially, there are only two primary methods to traverse through vector elements in reverse order. Methods Used There are two methods used here − ... Read More

Advertisements