Server Side Programming Articles - Page 2326 of 2650

Python Interfaces to Unix databases (dbm)

Anvi Jain
Updated on 30-Jul-2019 22:30:25

286 Views

The dbm package in Python's built-in library provides a dictionary like an interface DBM style databases. The dbm library is a simple database engine, written by Ken Thompson. DBM stands for DataBase Manager, used by UNIX operating system, the library stores arbitrary data by use of a single key (a primary key) in fixed-size buckets and uses hashing techniques to enable fast retrieval of the data by key.There are following modules in dbm package −The dbm.ndbm module provides an interface to the Unix “(n)dbm” library. Dbm objects behave like dictionaries, with keys and values should be stored as bytes. The ... Read More

Generate and parse Mac OS X .plist files using Python (plistlib)

Smita Kapse
Updated on 30-Jul-2019 22:30:25

2K+ Views

Files with '.plist' the extension is used by Mac OS X applications to store application properties. The plislib module provides an interface to read/write operations of these property list files.The plist file format serializes basic object types, like dictionaries, lists, numbers, and strings. Usually, the top level object is a dictionary. To write out and to parse a plist file, use the dump() and load() functions. Serialized byte strings are handled by use dumps() and loads() functions. Values can be strings, integers, floats, booleans, tuples, lists, dictionaries (but only with string keys).This module defines the following functions −load()Read a plist ... Read More

C++ Program to Find Fibonacci Numbers using Matrix Exponentiation

Nancy Den
Updated on 25-Apr-2025 14:17:38

3K+ Views

The Fibonacci numbers, commonly denoted as F(n) forms a sequence, called the Fibonacci sequence. In Fibonacci series, each number is the sum of the two previous two numbers, starting from 0 and 1. It is represented as F(n) = F(n-1) + F(n-2). The matrix exponentiation method is used to calculate the powers of matrix efficiently with better time complexity. In this article, we provide a value of n. This n is the value up to which we want to find the Fibonacci numbers using the matrix exponentiation method in C++. Here is an example of the Fibonacci series up to ... Read More

C++ Perform to a 2D FFT Inplace Given a Complex 2D Array

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

935 Views

Fast Fourier transform (FFT) is an algorithm to compute the discrete Fourier transform (DFT) and its inverse. Basically Fourier analysis converts time (or space) to frequency and vice versa. A FFT rapidly computes transformations by factorizing the DFT matrix into a product of sparse (mostly zero) factors.AlgorithmBegin    Declare the size of the array    Take the elements of the array    Declare three arrays    Initialize height =size of array and width=size of array    Create two outer loops to iterate on output data    Create two outer loops to iterate on input data    Compute real, img and ... Read More

C++ Program to Compute Discrete Fourier Transform Using Naive Approach

Ravi Ranjan
Updated on 26-May-2025 11:52:03

3K+ Views

DFT stands for Discrete Fourier Transform. DFT is a mathematical technique in which we convert the signals of the time domain to their respective signal in the frequency domain, i.e., converting into a list of numbers that tell us which frequencies are present in that signal. Here, by time signal, we mean signals such as audio, temperature, etc that changes over time. The frequency signal means the frequency of each signal present in the time signal. The numbers that tell us which frequencies are present in the signal are called the coefficients. In this article, our task is to compute ... Read More

C++ Program to Compute DFT Coefficients Directly

Ravi Ranjan
Updated on 26-May-2025 11:51:43

338 Views

DFT stands for Discrete Fourier Transform. DFT is a mathematical technique in which we convert the signals of the time domain to their respective signal in the frequency domain, i.e., converting into a list of numbers that tell us which frequencies are present in that signal. Here, by time signal, we mean signals such as audio, temperature, etc. that changes over time. The frequency signal means the frequency of each signal present in the time signal. The numbers that tell us which frequencies are present in the signal are called the coefficients. In this article, our task is to compute ... Read More

C++ Program to Implement the Bin Packing Algorithm

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

1K+ Views

The bin packing problem is a special type of cutting stock problem. In the bin packing problem, objects of different volumes must be packed into a finite number of containers or bins each of volume V in a way that minimizes the number of bins used. In computational complexity theory, it is a combinational NP-hard problem.When the number of bins is restricted to 1 and each item is characterized by both a volume and a value, the problem of maximizing the value of items that can fit in the bin is known as the knapsack problem.AlgorithmBegin    Binpacking(pointer, size, no ... Read More

C++ Program to Perform Partition of an Integer in All Possible Ways

Daniol Thomas
Updated on 28-Apr-2025 16:04:22

976 Views

In this article, we have a positive integer 'n'. Our task is to generate all possible unique ways to represent 'n' as the sum of positive integers in C++. Each partition should give a sum equal to the given 'n'. Here is an example: Input: n = 4 Output: 4 3 1 2 2 2 1 1 1 1 1 1 Steps to Perform Unique Partition of Integer We start with the current partition i.e. with an initial value of n. Then we print the current partition. ... Read More

C++ Program to Solve the Fractional Knapsack Problem

Daniol Thomas
Updated on 17-Feb-2022 13:07:35

7K+ Views

In Fractional knapsack problem, a set of items are given, each with a weight and a value. We need to break items for maximizing the total value of knapsack and this can be done in greedy approach.AlgorithmBegin Take an array of structure Item Declare value, weight, knapsack weight and density Calculate density=value/weight for each item Sorting the items array on the order of decreasing density We add values from the top of the array to total value until the bag is full, i.e; total value

C++ Program to Solve the 0-1 Knapsack Problem

Nancy Den
Updated on 29-Apr-2025 15:35:40

6K+ Views

In the 0-1 knapsack problem, a set of items is given, each with a weight and a value. We need to determine the number of each item to include in a collection so that the total weight is less than or equal to the given limit and the total value is as large as possible.ExampleThe following example explains the 0-1 knapsack problem: Input: Weights: 1 2 3 6 7 4 Values: 10 20 25 40 60 70 Max Weight Capacity: 7 Output: Maximum value: 100 Here is an explanation of the above example: Weights: ... Read More

Advertisements