Time and space complexity of algorithms

Catalog Article Directory 1. Time Complexity 2. Spatial Complexity 1. Time Complexity 1. Complexity: A measure of the efficiency of an algorithm 2. Concept: Time complexity mainly measures the speed of an algorithm, the number of basic operations in the algorithm, which is the time complexity of the algorithm. ...

Posted by gillypogi on Wed, 20 Oct 2021 11:28:10 -0700

Personal algorithm Beginner - greedy algorithm

Example: The best time to buy and sell stocks II Given an array prices, where   prices[i] is the price of a given stock on day I. Design an algorithm to calculate the maximum profit you can make. You can complete as many transactions as possible (buying and selling a stock multiple times). Note: you cannot participate in multiple t ...

Posted by WhiteHawk on Wed, 20 Oct 2021 11:15:10 -0700

csp-s2020 T1 Julian day

Title: [CSP-S2020] Julian day - Valleyhttps://www.luogu.com.cn/problem/P7075 After reading the question, we can see that this question is a simulation question about time. According to the meaning of the question: The time is divided into two periods: the Julian calendar from January 1, 4713 BC to October 4, 1582 ad (inclusive); October 15 ...

Posted by tmswenson on Tue, 19 Oct 2021 19:02:08 -0700

Quick sorting algorithm

Quicksort is an improvement of bubble sort algorithm. 1. Sorting process The quick sort algorithm realizes sorting through multiple comparisons and exchanges. The sorting process is as follows: (1) First, set a boundary value, and divide the array into left and right parts through the boundary value. (2) Collect data greater than or equal ...

Posted by silvercover on Tue, 19 Oct 2021 18:58:02 -0700

Heap sorting of graphical sorting algorithm

Preparatory knowledge Heap sort Heap sort is a sort algorithm designed by using the data structure of heap. Heap sort is a selective sort. Its worst, best, average time complexity is O(nlogn), and it is also an unstable sort. First, simply understand the lower heap structure. heap Heap is a complete binary tree with the following pro ...

Posted by I Am Chris on Tue, 19 Oct 2021 12:36:51 -0700

The 45th international undergraduate Programming Competition (ICPC) Asian regional competition (Nanjing)

E Evil Coordinate Simulation + thinking Here's a question for you U L R D ULRD ULRD is a string of four characters, U U ...

Posted by sliilvia on Tue, 19 Oct 2021 11:28:00 -0700

Front end "N Queen" recursive backtracking

/* @Author: yang@Date: 2021-09-27 19:40:34@LastEditors: yang@LastEditTime: 2021-10-19 19:57:43@FilePath: \demo \ breadth first traversal. js */ Front end "N Queen" recursive backtracking classical problem Let's look at the problem first. In fact, the problem is not difficult to understand: The n queen problem studies how to place n ...

Posted by Octave91 on Tue, 19 Oct 2021 11:19:09 -0700

Data Structure Experimentation Report - Merging Algorithm of Two Ordered Linear Tables

1. Contents and requirements of the experiment: 1. Create two ordered linear tables from keyboard input (input data of each linear table is entered in order from smallest to largest, regardless of sorting algorithm); Output the two ordered linear tables; Merge the two ordered linear tables into an ordered linear table. The output is a merged o ...

Posted by Tryweryn on Tue, 19 Oct 2021 09:26:54 -0700

c# realize mahjong Hu card judgment - pair method

Mahjong Foundation Before introducing the code, let's introduce the basis of Mahjong: There are 4 pieces of 10000-90000, 4 pieces of 1-9 cake, 4 pieces of 1-9 rope and 4 pieces of southeast and northwest white hair in a pair of mahjong cards The three consecutive cards of 10000, cake and flower color are called shunzi, for example: 12000, ...

Posted by bpgillett on Mon, 18 Oct 2021 20:55:38 -0700

[CF321D]Ciel and Flipboard

Ciel and Flipboard Problem solution We define s ( i , j ) s(i,j) s(i,j) indicates a ...

Posted by safra on Mon, 18 Oct 2021 13:48:37 -0700