• bitcoin, Donald Trump, US bitcoin mining, tariffs, cryptocurrency, economic ambitions, mining capital, blockchain technology, digital currency, American economy

    ## Introduction

    In a world increasingly driven by technology and innovation, the dream of an all-American Bitcoin stands as a beacon of hope for many. President Donald Trump once envisioned the United States as the undisputed capital of Bitcoin mining, a hub where the digital currency thrives and flourishes. However, as the winds of ec...
    bitcoin, Donald Trump, US bitcoin mining, tariffs, cryptocurrency, economic ambitions, mining capital, blockchain technology, digital currency, American economy ## Introduction In a world increasingly driven by technology and innovation, the dream of an all-American Bitcoin stands as a beacon of hope for many. President Donald Trump once envisioned the United States as the undisputed capital of Bitcoin mining, a hub where the digital currency thrives and flourishes. However, as the winds of ec...
    A False Start on the Road to an All-American Bitcoin
    bitcoin, Donald Trump, US bitcoin mining, tariffs, cryptocurrency, economic ambitions, mining capital, blockchain technology, digital currency, American economy ## Introduction In a world increasingly driven by technology and innovation, the dream of an all-American Bitcoin stands as a beacon of hope for many. President Donald Trump once envisioned the United States as the undisputed capital...
    Like
    Love
    Wow
    Angry
    Sad
    139
    1 Комментарии 0 Поделились
  • Time Complexity of Sorting Algorithms in Python, Java, and C++

    Posted on : June 13, 2025

    By

    Tech World Times

    Development and Testing 

    Rate this post

    Sorting helps organize data in a specific order. It is used in search, reports, and efficient storage. Different sorting algorithms offer different performance. In this article, we will explain the Time Complexity of Sorting Algorithms in simple words. We will cover Python, Java, and C++ examples.
    1. What Is Time Complexity?
    Time complexity tells how fast an algorithm runs. It measures the number of steps as input grows. It is written in Big-O notation. For example, Omeans steps grow with the square of inputs.
    2. Types of Time Complexity
    Here are common types:

    O: Constant time
    O: Linear time
    O: Log-linear time
    O: Quadratic time

    We will now apply these to sorting.
    3. Bubble Sort
    Bubble Sort compares two numbers and swaps them if needed. It repeats until the list is sorted.
    Time Complexity:

    Best Case: OAverage Case: OWorst Case: OPython Example:
    pythonCopyEditdef bubble_sort:
    n = lenfor i in range:
    for j in range:
    if arr> arr:
    arr, arr= arr, arrJava Example:
    javaCopyEditvoid bubbleSort{
    int n = arr.length;
    forforif{
    int temp = arr;
    arr= arr;
    arr= temp;
    }
    }

    C++ Example:
    cppCopyEditvoid bubbleSort{
    forforifswap;
    }

    4. Selection Sort
    This sort picks the smallest number and places it at the front.
    Time Complexity:

    Best Case: OAverage Case: OWorst Case: OPython Example:
    pythonCopyEditdef selection_sort:
    for i in range):
    min_idx = i
    for j in range):
    if arr< arr:
    min_idx = j
    arr, arr= arr, arr5. Insertion Sort
    This algorithm builds the final list one item at a time.
    Time Complexity:

    Best Case: OAverage Case: OWorst Case: OJava Example:
    javaCopyEditvoid insertionSort{
    for{
    int key = arr;
    int j = i - 1;
    while{
    arr= arr;
    j = j - 1;
    }
    arr= key;
    }
    }

    6. Merge Sort
    Merge Sort splits the array into halves and merges them back in order.
    Time Complexity of Sorting Algorithms like Merge Sort is usually better.

    Best Case: OAverage Case: OWorst Case: OPython Example:
    pythonCopyEditdef merge_sort:
    if len> 1:
    mid = len// 2
    left = arrright = arrmerge_sortmerge_sorti = j = k = 0
    while i < lenand j < len:
    if left< right:
    arr= lefti += 1
    else:
    arr= rightj += 1
    k += 1

    arr= left+ right7. Quick Sort
    Quick Sort picks a pivot and places smaller numbers before it.
    Time Complexity:

    Best Case: OAverage Case: OWorst Case: OC++ Example:
    cppCopyEditint partition{
    int pivot = arr;
    int i = low - 1;
    for{
    if{
    i++;
    swap;
    }
    }
    swap;
    return i + 1;
    }

    void quickSort{
    if{
    int pi = partition;
    quickSort;
    quickSort;
    }
    }

    8. Built-in Sort Methods
    Languages have built-in sort functions. These are well-optimized.

    Python: sortedor list.sortuses TimSort

    Time Complexity: OJava: Arrays.sortuses Dual-Pivot QuickSort

    Time Complexity: OC++: std::sortuses IntroSort

    Time Complexity: OThese are better for most real-world tasks.
    9. Time Complexity Comparison Table
    AlgorithmBestAverageWorstStableBubble SortOOOYesSelection SortOOONoInsertion SortOOOYesMerge SortOOOYesQuick SortOOONoTimSortOOOYesIntroSortOOONo
    10. How to Choose the Right Algorithm?

    Use Merge Sort for large stable data.
    Use Quick Sort for faster average speed.
    Use Insertion Sort for small or nearly sorted lists.
    Use built-in sort functions unless you need control.

    Conclusion
    The Time Complexity of Sorting Algorithms helps us pick the right tool. Bubble, Selection, and Insertion Sort are simple but slow. Merge and Quick Sort are faster and used often. Built-in functions are highly optimized. Python, Java, and C++ each have their strengths.
    Understand your problem and input size. Then pick the sorting method. This ensures better speed and performance in your code.
    Tech World TimesTech World Times, a global collective focusing on the latest tech news and trends in blockchain, Fintech, Development & Testing, AI and Startups. If you are looking for the guest post then contact at techworldtimes@gmail.com
    #time #complexity #sorting #algorithms #python
    Time Complexity of Sorting Algorithms in Python, Java, and C++
    Posted on : June 13, 2025 By Tech World Times Development and Testing  Rate this post Sorting helps organize data in a specific order. It is used in search, reports, and efficient storage. Different sorting algorithms offer different performance. In this article, we will explain the Time Complexity of Sorting Algorithms in simple words. We will cover Python, Java, and C++ examples. 1. What Is Time Complexity? Time complexity tells how fast an algorithm runs. It measures the number of steps as input grows. It is written in Big-O notation. For example, Omeans steps grow with the square of inputs. 2. Types of Time Complexity Here are common types: O: Constant time O: Linear time O: Log-linear time O: Quadratic time We will now apply these to sorting. 3. Bubble Sort Bubble Sort compares two numbers and swaps them if needed. It repeats until the list is sorted. Time Complexity: Best Case: OAverage Case: OWorst Case: OPython Example: pythonCopyEditdef bubble_sort: n = lenfor i in range: for j in range: if arr> arr: arr, arr= arr, arrJava Example: javaCopyEditvoid bubbleSort{ int n = arr.length; forforif{ int temp = arr; arr= arr; arr= temp; } } C++ Example: cppCopyEditvoid bubbleSort{ forforifswap; } 4. Selection Sort This sort picks the smallest number and places it at the front. Time Complexity: Best Case: OAverage Case: OWorst Case: OPython Example: pythonCopyEditdef selection_sort: for i in range): min_idx = i for j in range): if arr< arr: min_idx = j arr, arr= arr, arr5. Insertion Sort This algorithm builds the final list one item at a time. Time Complexity: Best Case: OAverage Case: OWorst Case: OJava Example: javaCopyEditvoid insertionSort{ for{ int key = arr; int j = i - 1; while{ arr= arr; j = j - 1; } arr= key; } } 6. Merge Sort Merge Sort splits the array into halves and merges them back in order. Time Complexity of Sorting Algorithms like Merge Sort is usually better. Best Case: OAverage Case: OWorst Case: OPython Example: pythonCopyEditdef merge_sort: if len> 1: mid = len// 2 left = arrright = arrmerge_sortmerge_sorti = j = k = 0 while i < lenand j < len: if left< right: arr= lefti += 1 else: arr= rightj += 1 k += 1 arr= left+ right7. Quick Sort Quick Sort picks a pivot and places smaller numbers before it. Time Complexity: Best Case: OAverage Case: OWorst Case: OC++ Example: cppCopyEditint partition{ int pivot = arr; int i = low - 1; for{ if{ i++; swap; } } swap; return i + 1; } void quickSort{ if{ int pi = partition; quickSort; quickSort; } } 8. Built-in Sort Methods Languages have built-in sort functions. These are well-optimized. Python: sortedor list.sortuses TimSort Time Complexity: OJava: Arrays.sortuses Dual-Pivot QuickSort Time Complexity: OC++: std::sortuses IntroSort Time Complexity: OThese are better for most real-world tasks. 9. Time Complexity Comparison Table AlgorithmBestAverageWorstStableBubble SortOOOYesSelection SortOOONoInsertion SortOOOYesMerge SortOOOYesQuick SortOOONoTimSortOOOYesIntroSortOOONo 10. How to Choose the Right Algorithm? Use Merge Sort for large stable data. Use Quick Sort for faster average speed. Use Insertion Sort for small or nearly sorted lists. Use built-in sort functions unless you need control. Conclusion The Time Complexity of Sorting Algorithms helps us pick the right tool. Bubble, Selection, and Insertion Sort are simple but slow. Merge and Quick Sort are faster and used often. Built-in functions are highly optimized. Python, Java, and C++ each have their strengths. Understand your problem and input size. Then pick the sorting method. This ensures better speed and performance in your code. Tech World TimesTech World Times, a global collective focusing on the latest tech news and trends in blockchain, Fintech, Development & Testing, AI and Startups. If you are looking for the guest post then contact at techworldtimes@gmail.com #time #complexity #sorting #algorithms #python
    TECHWORLDTIMES.COM
    Time Complexity of Sorting Algorithms in Python, Java, and C++
    Posted on : June 13, 2025 By Tech World Times Development and Testing  Rate this post Sorting helps organize data in a specific order. It is used in search, reports, and efficient storage. Different sorting algorithms offer different performance. In this article, we will explain the Time Complexity of Sorting Algorithms in simple words. We will cover Python, Java, and C++ examples. 1. What Is Time Complexity? Time complexity tells how fast an algorithm runs. It measures the number of steps as input grows. It is written in Big-O notation. For example, O(n²) means steps grow with the square of inputs. 2. Types of Time Complexity Here are common types: O(1): Constant time O(n): Linear time O(n log n): Log-linear time O(n²): Quadratic time We will now apply these to sorting. 3. Bubble Sort Bubble Sort compares two numbers and swaps them if needed. It repeats until the list is sorted. Time Complexity: Best Case: O(n) (if already sorted) Average Case: O(n²) Worst Case: O(n²) Python Example: pythonCopyEditdef bubble_sort(arr): n = len(arr) for i in range(n): for j in range(n - i - 1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] Java Example: javaCopyEditvoid bubbleSort(int arr[]) { int n = arr.length; for (int i = 0; i < n-1; i++) for (int j = 0; j < n-i-1; j++) if (arr[j] > arr[j+1]) { int temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } } C++ Example: cppCopyEditvoid bubbleSort(int arr[], int n) { for (int i = 0; i < n-1; i++) for (int j = 0; j < n-i-1; j++) if (arr[j] > arr[j+1]) swap(arr[j], arr[j+1]); } 4. Selection Sort This sort picks the smallest number and places it at the front. Time Complexity: Best Case: O(n²) Average Case: O(n²) Worst Case: O(n²) Python Example: pythonCopyEditdef selection_sort(arr): for i in range(len(arr)): min_idx = i for j in range(i+1, len(arr)): if arr[j] < arr[min_idx]: min_idx = j arr[i], arr[min_idx] = arr[min_idx], arr[i] 5. Insertion Sort This algorithm builds the final list one item at a time. Time Complexity: Best Case: O(n) Average Case: O(n²) Worst Case: O(n²) Java Example: javaCopyEditvoid insertionSort(int arr[]) { for (int i = 1; i < arr.length; i++) { int key = arr[i]; int j = i - 1; while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]; j = j - 1; } arr[j + 1] = key; } } 6. Merge Sort Merge Sort splits the array into halves and merges them back in order. Time Complexity of Sorting Algorithms like Merge Sort is usually better. Best Case: O(n log n) Average Case: O(n log n) Worst Case: O(n log n) Python Example: pythonCopyEditdef merge_sort(arr): if len(arr) > 1: mid = len(arr) // 2 left = arr[:mid] right = arr[mid:] merge_sort(left) merge_sort(right) i = j = k = 0 while i < len(left) and j < len(right): if left[i] < right[j]: arr[k] = left[i] i += 1 else: arr[k] = right[j] j += 1 k += 1 arr[k:] = left[i:] + right[j:] 7. Quick Sort Quick Sort picks a pivot and places smaller numbers before it. Time Complexity: Best Case: O(n log n) Average Case: O(n log n) Worst Case: O(n²) C++ Example: cppCopyEditint partition(int arr[], int low, int high) { int pivot = arr[high]; int i = low - 1; for (int j = low; j < high; j++) { if (arr[j] < pivot) { i++; swap(arr[i], arr[j]); } } swap(arr[i+1], arr[high]); return i + 1; } void quickSort(int arr[], int low, int high) { if (low < high) { int pi = partition(arr, low, high); quickSort(arr, low, pi - 1); quickSort(arr, pi + 1, high); } } 8. Built-in Sort Methods Languages have built-in sort functions. These are well-optimized. Python: sorted() or list.sort() uses TimSort Time Complexity: O(n log n) Java: Arrays.sort() uses Dual-Pivot QuickSort Time Complexity: O(n log n) C++: std::sort() uses IntroSort Time Complexity: O(n log n) These are better for most real-world tasks. 9. Time Complexity Comparison Table AlgorithmBestAverageWorstStableBubble SortO(n)O(n²)O(n²)YesSelection SortO(n²)O(n²)O(n²)NoInsertion SortO(n)O(n²)O(n²)YesMerge SortO(n log n)O(n log n)O(n log n)YesQuick SortO(n log n)O(n log n)O(n²)NoTimSort (Python)O(n)O(n log n)O(n log n)YesIntroSort (C++)O(n log n)O(n log n)O(n log n)No 10. How to Choose the Right Algorithm? Use Merge Sort for large stable data. Use Quick Sort for faster average speed. Use Insertion Sort for small or nearly sorted lists. Use built-in sort functions unless you need control. Conclusion The Time Complexity of Sorting Algorithms helps us pick the right tool. Bubble, Selection, and Insertion Sort are simple but slow. Merge and Quick Sort are faster and used often. Built-in functions are highly optimized. Python, Java, and C++ each have their strengths. Understand your problem and input size. Then pick the sorting method. This ensures better speed and performance in your code. Tech World TimesTech World Times (TWT), a global collective focusing on the latest tech news and trends in blockchain, Fintech, Development & Testing, AI and Startups. If you are looking for the guest post then contact at techworldtimes@gmail.com
    Like
    Love
    Wow
    Sad
    Angry
    570
    2 Комментарии 0 Поделились
  • Malicious PyPI Package Masquerades as Chimera Module to Steal AWS, CI/CD, and macOS Data

    Jun 16, 2025Ravie LakshmananMalware / DevOps

    Cybersecurity researchers have discovered a malicious package on the Python Package Indexrepository that's capable of harvesting sensitive developer-related information, such as credentials, configuration data, and environment variables, among others.
    The package, named chimera-sandbox-extensions, attracted 143 downloads and likely targets users of a service called Chimera Sandbox, which was released by Singaporean tech company Grab last August to facilitate "experimentation and development ofsolutions."
    The package masquerades as a helper module for Chimera Sandbox, but "aims to steal credentials and other sensitive information such as Jamf configuration, CI/CD environment variables, AWS tokens, and more," JFrog security researcher Guy Korolevski said in a report published last week.
    Once installed, it attempts to connect to an external domain whose domain name is generated using a domain generation algorithmin order to download and execute a next-stage payload.
    Specifically, the malware acquires from the domain an authentication token, which is then used to send a request to the same domain and retrieve the Python-based information stealer.

    The stealer malware is equipped to siphon a wide range of data from infected machines. This includes -

    JAMF receipts, which are records of software packages installed by Jamf Pro on managed computers
    Pod sandbox environment authentication tokens and git information
    CI/CD information from environment variables
    Zscaler host configuration
    Amazon Web Services account information and tokens
    Public IP address
    General platform, user, and host information

    The kind of data gathered by the malware shows that it's mainly geared towards corporate and cloud infrastructure. In addition, the extraction of JAMF receipts indicates that it's also capable of targeting Apple macOS systems.
    The collected information is sent via a POST request back to the same domain, after which the server assesses if the machine is a worthy target for further exploitation. However, JFrog said it was unable to obtain the payload at the time of analysis.
    "The targeted approach employed by this malware, along with the complexity of its multi-stage targeted payload, distinguishes it from the more generic open-source malware threats we have encountered thus far, highlighting the advancements that malicious packages have made recently," Jonathan Sar Shalom, director of threat research at JFrog Security Research team, said.

    "This new sophistication of malware underscores why development teams remain vigilant with updates—alongside proactive security research – to defend against emerging threats and maintain software integrity."
    The disclosure comes as SafeDep and Veracode detailed a number of malware-laced npm packages that are designed to execute remote code and download additional payloads. The packages in question are listed below -

    eslint-config-airbnb-compatts-runtime-compat-checksolders@mediawave/libAll the identified npm packages have since been taken down from npm, but not before they were downloaded hundreds of times from the package registry.
    SafeDep's analysis of eslint-config-airbnb-compat found that the JavaScript library has ts-runtime-compat-check listed as a dependency, which, in turn, contacts an external server defined in the former packageto retrieve and execute a Base64-encoded string. The exact nature of the payload is unknown.
    "It implements a multi-stage remote code execution attack using a transitive dependency to hide the malicious code," SafeDep researcher Kunal Singh said.
    Solders, on the other hand, has been found to incorporate a post-install script in its package.json, causing the malicious code to be automatically executed as soon as the package is installed.
    "At first glance, it's hard to believe that this is actually valid JavaScript," the Veracode Threat Research team said. "It looks like a seemingly random collection of Japanese symbols. It turns out that this particular obfuscation scheme uses the Unicode characters as variable names and a sophisticated chain of dynamic code generation to work."
    Decoding the script reveals an extra layer of obfuscation, unpacking which reveals its main function: Check if the compromised machine is Windows, and if so, run a PowerShell command to retrieve a next-stage payload from a remote server.
    This second-stage PowerShell script, also obscured, is designed to fetch a Windows batch script from another domainand configures a Windows Defender Antivirus exclusion list to avoid detection. The batch script then paves the way for the execution of a .NET DLL that reaches out to a PNG image hosted on ImgBB.
    "is grabbing the last two pixels from this image and then looping through some data contained elsewhere in it," Veracode said. "It ultimately builds up in memory YET ANOTHER .NET DLL."

    Furthermore, the DLL is equipped to create task scheduler entries and features the ability to bypass user account controlusing a combination of FodHelper.exe and programmatic identifiersto evade defenses and avoid triggering any security alerts to the user.
    The newly-downloaded DLL is Pulsar RAT, a "free, open-source Remote Administration Tool for Windows" and a variant of the Quasar RAT.
    "From a wall of Japanese characters to a RAT hidden within the pixels of a PNG file, the attacker went to extraordinary lengths to conceal their payload, nesting it a dozen layers deep to evade detection," Veracode said. "While the attacker's ultimate objective for deploying the Pulsar RAT remains unclear, the sheer complexity of this delivery mechanism is a powerful indicator of malicious intent."
    Crypto Malware in the Open-Source Supply Chain
    The findings also coincide with a report from Socket that identified credential stealers, cryptocurrency drainers, cryptojackers, and clippers as the main types of threats targeting the cryptocurrency and blockchain development ecosystem.

    Some of the examples of these packages include -

    express-dompurify and pumptoolforvolumeandcomment, which are capable of harvesting browser credentials and cryptocurrency wallet keys
    bs58js, which drains a victim's wallet and uses multi-hop transfers to obscure theft and frustrate forensic tracing.
    lsjglsjdv, asyncaiosignal, and raydium-sdk-liquidity-init, which functions as a clipper to monitor the system clipboard for cryptocurrency wallet strings and replace them with threat actor‑controlled addresses to reroute transactions to the attackers

    "As Web3 development converges with mainstream software engineering, the attack surface for blockchain-focused projects is expanding in both scale and complexity," Socket security researcher Kirill Boychenko said.
    "Financially motivated threat actors and state-sponsored groups are rapidly evolving their tactics to exploit systemic weaknesses in the software supply chain. These campaigns are iterative, persistent, and increasingly tailored to high-value targets."
    AI and Slopsquatting
    The rise of artificial intelligence-assisted coding, also called vibe coding, has unleashed another novel threat in the form of slopsquatting, where large language modelscan hallucinate non-existent but plausible package names that bad actors can weaponize to conduct supply chain attacks.
    Trend Micro, in a report last week, said it observed an unnamed advanced agent "confidently" cooking up a phantom Python package named starlette-reverse-proxy, only for the build process to crash with the error "module not found." However, should an adversary upload a package with the same name on the repository, it can have serious security consequences.

    Furthermore, the cybersecurity company noted that advanced coding agents and workflows such as Claude Code CLI, OpenAI Codex CLI, and Cursor AI with Model Context Protocol-backed validation can help reduce, but not completely eliminate, the risk of slopsquatting.
    "When agents hallucinate dependencies or install unverified packages, they create an opportunity for slopsquatting attacks, in which malicious actors pre-register those same hallucinated names on public registries," security researcher Sean Park said.
    "While reasoning-enhanced agents can reduce the rate of phantom suggestions by approximately half, they do not eliminate them entirely. Even the vibe-coding workflow augmented with live MCP validations achieves the lowest rates of slip-through, but still misses edge cases."

    Found this article interesting? Follow us on Twitter  and LinkedIn to read more exclusive content we post.

    SHARE




    #malicious #pypi #package #masquerades #chimera
    Malicious PyPI Package Masquerades as Chimera Module to Steal AWS, CI/CD, and macOS Data
    Jun 16, 2025Ravie LakshmananMalware / DevOps Cybersecurity researchers have discovered a malicious package on the Python Package Indexrepository that's capable of harvesting sensitive developer-related information, such as credentials, configuration data, and environment variables, among others. The package, named chimera-sandbox-extensions, attracted 143 downloads and likely targets users of a service called Chimera Sandbox, which was released by Singaporean tech company Grab last August to facilitate "experimentation and development ofsolutions." The package masquerades as a helper module for Chimera Sandbox, but "aims to steal credentials and other sensitive information such as Jamf configuration, CI/CD environment variables, AWS tokens, and more," JFrog security researcher Guy Korolevski said in a report published last week. Once installed, it attempts to connect to an external domain whose domain name is generated using a domain generation algorithmin order to download and execute a next-stage payload. Specifically, the malware acquires from the domain an authentication token, which is then used to send a request to the same domain and retrieve the Python-based information stealer. The stealer malware is equipped to siphon a wide range of data from infected machines. This includes - JAMF receipts, which are records of software packages installed by Jamf Pro on managed computers Pod sandbox environment authentication tokens and git information CI/CD information from environment variables Zscaler host configuration Amazon Web Services account information and tokens Public IP address General platform, user, and host information The kind of data gathered by the malware shows that it's mainly geared towards corporate and cloud infrastructure. In addition, the extraction of JAMF receipts indicates that it's also capable of targeting Apple macOS systems. The collected information is sent via a POST request back to the same domain, after which the server assesses if the machine is a worthy target for further exploitation. However, JFrog said it was unable to obtain the payload at the time of analysis. "The targeted approach employed by this malware, along with the complexity of its multi-stage targeted payload, distinguishes it from the more generic open-source malware threats we have encountered thus far, highlighting the advancements that malicious packages have made recently," Jonathan Sar Shalom, director of threat research at JFrog Security Research team, said. "This new sophistication of malware underscores why development teams remain vigilant with updates—alongside proactive security research – to defend against emerging threats and maintain software integrity." The disclosure comes as SafeDep and Veracode detailed a number of malware-laced npm packages that are designed to execute remote code and download additional payloads. The packages in question are listed below - eslint-config-airbnb-compatts-runtime-compat-checksolders@mediawave/libAll the identified npm packages have since been taken down from npm, but not before they were downloaded hundreds of times from the package registry. SafeDep's analysis of eslint-config-airbnb-compat found that the JavaScript library has ts-runtime-compat-check listed as a dependency, which, in turn, contacts an external server defined in the former packageto retrieve and execute a Base64-encoded string. The exact nature of the payload is unknown. "It implements a multi-stage remote code execution attack using a transitive dependency to hide the malicious code," SafeDep researcher Kunal Singh said. Solders, on the other hand, has been found to incorporate a post-install script in its package.json, causing the malicious code to be automatically executed as soon as the package is installed. "At first glance, it's hard to believe that this is actually valid JavaScript," the Veracode Threat Research team said. "It looks like a seemingly random collection of Japanese symbols. It turns out that this particular obfuscation scheme uses the Unicode characters as variable names and a sophisticated chain of dynamic code generation to work." Decoding the script reveals an extra layer of obfuscation, unpacking which reveals its main function: Check if the compromised machine is Windows, and if so, run a PowerShell command to retrieve a next-stage payload from a remote server. This second-stage PowerShell script, also obscured, is designed to fetch a Windows batch script from another domainand configures a Windows Defender Antivirus exclusion list to avoid detection. The batch script then paves the way for the execution of a .NET DLL that reaches out to a PNG image hosted on ImgBB. "is grabbing the last two pixels from this image and then looping through some data contained elsewhere in it," Veracode said. "It ultimately builds up in memory YET ANOTHER .NET DLL." Furthermore, the DLL is equipped to create task scheduler entries and features the ability to bypass user account controlusing a combination of FodHelper.exe and programmatic identifiersto evade defenses and avoid triggering any security alerts to the user. The newly-downloaded DLL is Pulsar RAT, a "free, open-source Remote Administration Tool for Windows" and a variant of the Quasar RAT. "From a wall of Japanese characters to a RAT hidden within the pixels of a PNG file, the attacker went to extraordinary lengths to conceal their payload, nesting it a dozen layers deep to evade detection," Veracode said. "While the attacker's ultimate objective for deploying the Pulsar RAT remains unclear, the sheer complexity of this delivery mechanism is a powerful indicator of malicious intent." Crypto Malware in the Open-Source Supply Chain The findings also coincide with a report from Socket that identified credential stealers, cryptocurrency drainers, cryptojackers, and clippers as the main types of threats targeting the cryptocurrency and blockchain development ecosystem. Some of the examples of these packages include - express-dompurify and pumptoolforvolumeandcomment, which are capable of harvesting browser credentials and cryptocurrency wallet keys bs58js, which drains a victim's wallet and uses multi-hop transfers to obscure theft and frustrate forensic tracing. lsjglsjdv, asyncaiosignal, and raydium-sdk-liquidity-init, which functions as a clipper to monitor the system clipboard for cryptocurrency wallet strings and replace them with threat actor‑controlled addresses to reroute transactions to the attackers "As Web3 development converges with mainstream software engineering, the attack surface for blockchain-focused projects is expanding in both scale and complexity," Socket security researcher Kirill Boychenko said. "Financially motivated threat actors and state-sponsored groups are rapidly evolving their tactics to exploit systemic weaknesses in the software supply chain. These campaigns are iterative, persistent, and increasingly tailored to high-value targets." AI and Slopsquatting The rise of artificial intelligence-assisted coding, also called vibe coding, has unleashed another novel threat in the form of slopsquatting, where large language modelscan hallucinate non-existent but plausible package names that bad actors can weaponize to conduct supply chain attacks. Trend Micro, in a report last week, said it observed an unnamed advanced agent "confidently" cooking up a phantom Python package named starlette-reverse-proxy, only for the build process to crash with the error "module not found." However, should an adversary upload a package with the same name on the repository, it can have serious security consequences. Furthermore, the cybersecurity company noted that advanced coding agents and workflows such as Claude Code CLI, OpenAI Codex CLI, and Cursor AI with Model Context Protocol-backed validation can help reduce, but not completely eliminate, the risk of slopsquatting. "When agents hallucinate dependencies or install unverified packages, they create an opportunity for slopsquatting attacks, in which malicious actors pre-register those same hallucinated names on public registries," security researcher Sean Park said. "While reasoning-enhanced agents can reduce the rate of phantom suggestions by approximately half, they do not eliminate them entirely. Even the vibe-coding workflow augmented with live MCP validations achieves the lowest rates of slip-through, but still misses edge cases." Found this article interesting? Follow us on Twitter  and LinkedIn to read more exclusive content we post. SHARE     #malicious #pypi #package #masquerades #chimera
    THEHACKERNEWS.COM
    Malicious PyPI Package Masquerades as Chimera Module to Steal AWS, CI/CD, and macOS Data
    Jun 16, 2025Ravie LakshmananMalware / DevOps Cybersecurity researchers have discovered a malicious package on the Python Package Index (PyPI) repository that's capable of harvesting sensitive developer-related information, such as credentials, configuration data, and environment variables, among others. The package, named chimera-sandbox-extensions, attracted 143 downloads and likely targets users of a service called Chimera Sandbox, which was released by Singaporean tech company Grab last August to facilitate "experimentation and development of [machine learning] solutions." The package masquerades as a helper module for Chimera Sandbox, but "aims to steal credentials and other sensitive information such as Jamf configuration, CI/CD environment variables, AWS tokens, and more," JFrog security researcher Guy Korolevski said in a report published last week. Once installed, it attempts to connect to an external domain whose domain name is generated using a domain generation algorithm (DGA) in order to download and execute a next-stage payload. Specifically, the malware acquires from the domain an authentication token, which is then used to send a request to the same domain and retrieve the Python-based information stealer. The stealer malware is equipped to siphon a wide range of data from infected machines. This includes - JAMF receipts, which are records of software packages installed by Jamf Pro on managed computers Pod sandbox environment authentication tokens and git information CI/CD information from environment variables Zscaler host configuration Amazon Web Services account information and tokens Public IP address General platform, user, and host information The kind of data gathered by the malware shows that it's mainly geared towards corporate and cloud infrastructure. In addition, the extraction of JAMF receipts indicates that it's also capable of targeting Apple macOS systems. The collected information is sent via a POST request back to the same domain, after which the server assesses if the machine is a worthy target for further exploitation. However, JFrog said it was unable to obtain the payload at the time of analysis. "The targeted approach employed by this malware, along with the complexity of its multi-stage targeted payload, distinguishes it from the more generic open-source malware threats we have encountered thus far, highlighting the advancements that malicious packages have made recently," Jonathan Sar Shalom, director of threat research at JFrog Security Research team, said. "This new sophistication of malware underscores why development teams remain vigilant with updates—alongside proactive security research – to defend against emerging threats and maintain software integrity." The disclosure comes as SafeDep and Veracode detailed a number of malware-laced npm packages that are designed to execute remote code and download additional payloads. The packages in question are listed below - eslint-config-airbnb-compat (676 Downloads) ts-runtime-compat-check (1,588 Downloads) solders (983 Downloads) @mediawave/lib (386 Downloads) All the identified npm packages have since been taken down from npm, but not before they were downloaded hundreds of times from the package registry. SafeDep's analysis of eslint-config-airbnb-compat found that the JavaScript library has ts-runtime-compat-check listed as a dependency, which, in turn, contacts an external server defined in the former package ("proxy.eslint-proxy[.]site") to retrieve and execute a Base64-encoded string. The exact nature of the payload is unknown. "It implements a multi-stage remote code execution attack using a transitive dependency to hide the malicious code," SafeDep researcher Kunal Singh said. Solders, on the other hand, has been found to incorporate a post-install script in its package.json, causing the malicious code to be automatically executed as soon as the package is installed. "At first glance, it's hard to believe that this is actually valid JavaScript," the Veracode Threat Research team said. "It looks like a seemingly random collection of Japanese symbols. It turns out that this particular obfuscation scheme uses the Unicode characters as variable names and a sophisticated chain of dynamic code generation to work." Decoding the script reveals an extra layer of obfuscation, unpacking which reveals its main function: Check if the compromised machine is Windows, and if so, run a PowerShell command to retrieve a next-stage payload from a remote server ("firewall[.]tel"). This second-stage PowerShell script, also obscured, is designed to fetch a Windows batch script from another domain ("cdn.audiowave[.]org") and configures a Windows Defender Antivirus exclusion list to avoid detection. The batch script then paves the way for the execution of a .NET DLL that reaches out to a PNG image hosted on ImgBB ("i.ibb[.]co"). "[The DLL] is grabbing the last two pixels from this image and then looping through some data contained elsewhere in it," Veracode said. "It ultimately builds up in memory YET ANOTHER .NET DLL." Furthermore, the DLL is equipped to create task scheduler entries and features the ability to bypass user account control (UAC) using a combination of FodHelper.exe and programmatic identifiers (ProgIDs) to evade defenses and avoid triggering any security alerts to the user. The newly-downloaded DLL is Pulsar RAT, a "free, open-source Remote Administration Tool for Windows" and a variant of the Quasar RAT. "From a wall of Japanese characters to a RAT hidden within the pixels of a PNG file, the attacker went to extraordinary lengths to conceal their payload, nesting it a dozen layers deep to evade detection," Veracode said. "While the attacker's ultimate objective for deploying the Pulsar RAT remains unclear, the sheer complexity of this delivery mechanism is a powerful indicator of malicious intent." Crypto Malware in the Open-Source Supply Chain The findings also coincide with a report from Socket that identified credential stealers, cryptocurrency drainers, cryptojackers, and clippers as the main types of threats targeting the cryptocurrency and blockchain development ecosystem. Some of the examples of these packages include - express-dompurify and pumptoolforvolumeandcomment, which are capable of harvesting browser credentials and cryptocurrency wallet keys bs58js, which drains a victim's wallet and uses multi-hop transfers to obscure theft and frustrate forensic tracing. lsjglsjdv, asyncaiosignal, and raydium-sdk-liquidity-init, which functions as a clipper to monitor the system clipboard for cryptocurrency wallet strings and replace them with threat actor‑controlled addresses to reroute transactions to the attackers "As Web3 development converges with mainstream software engineering, the attack surface for blockchain-focused projects is expanding in both scale and complexity," Socket security researcher Kirill Boychenko said. "Financially motivated threat actors and state-sponsored groups are rapidly evolving their tactics to exploit systemic weaknesses in the software supply chain. These campaigns are iterative, persistent, and increasingly tailored to high-value targets." AI and Slopsquatting The rise of artificial intelligence (AI)-assisted coding, also called vibe coding, has unleashed another novel threat in the form of slopsquatting, where large language models (LLMs) can hallucinate non-existent but plausible package names that bad actors can weaponize to conduct supply chain attacks. Trend Micro, in a report last week, said it observed an unnamed advanced agent "confidently" cooking up a phantom Python package named starlette-reverse-proxy, only for the build process to crash with the error "module not found." However, should an adversary upload a package with the same name on the repository, it can have serious security consequences. Furthermore, the cybersecurity company noted that advanced coding agents and workflows such as Claude Code CLI, OpenAI Codex CLI, and Cursor AI with Model Context Protocol (MCP)-backed validation can help reduce, but not completely eliminate, the risk of slopsquatting. "When agents hallucinate dependencies or install unverified packages, they create an opportunity for slopsquatting attacks, in which malicious actors pre-register those same hallucinated names on public registries," security researcher Sean Park said. "While reasoning-enhanced agents can reduce the rate of phantom suggestions by approximately half, they do not eliminate them entirely. Even the vibe-coding workflow augmented with live MCP validations achieves the lowest rates of slip-through, but still misses edge cases." Found this article interesting? Follow us on Twitter  and LinkedIn to read more exclusive content we post. SHARE    
    Like
    Love
    Wow
    Sad
    Angry
    514
    2 Комментарии 0 Поделились
  • How to Implement Insertion Sort in Java: Step-by-Step Guide

    Posted on : June 13, 2025

    By

    Tech World Times

    Uncategorized 

    Rate this post

    Sorting is important in programming. It helps organize data. Sorting improves performance in searching, analysis, and reporting. There are many sorting algorithms. One of the simplest is Insertion Sort.
    In this article, we will learn how to implement Insertion Sort in Java. We will explain each step in simple words. You will see examples and understand how it works.
    What Is Insertion Sort?
    Insertion Sort is a simple sorting algorithm. It works like how you sort playing cards. You take one card at a time and place it in the right position. It compares the current element with those before it. If needed, it shifts elements to the right. Then, it inserts the current element at the correct place.
    How Insertion Sort Works
    Let’s understand with a small list:
    Example List:Steps:

    First elementis already sorted.
    Compare 3 with 8. Move 8 right. Insert 3 before it →Compare 5 with 8. Move 8 right. Insert 5 after 3 →Compare 1 with 8, 5, 3. Move them right. Insert 1 at start →Now the list is sorted!
    Why Use Insertion Sort?
    Insertion Sort is simple and easy to code. It works well for:

    Small datasets
    Nearly sorted lists
    Educational purposes and practice

    However, it is not good for large datasets. It has a time complexity of O.
    Time Complexity of Insertion Sort

    Best Case: OAverage Case: OWorst Case: OIt performs fewer steps in nearly sorted data.
    How to Implement Insertion Sort in Java
    Now let’s write the code for Insertion Sort in Java. We will explain each part.
    Step 1: Define a Class
    javaCopyEditpublic class InsertionSortExample {
    // Code goes here
    }

    We create a class named InsertionSortExample.
    Step 2: Create the Sorting Method
    javaCopyEditpublic static void insertionSort{
    int n = arr.length;
    for{
    int key = arr;
    int j = i - 1;

    while{
    arr= arr;
    j = j - 1;
    }
    arr= key;
    }
    }

    Let’s break it down:

    arris the current value.
    j starts from the previous index.
    While arr> key, shift arrto the right.
    Insert the key at the correct position.

    This logic sorts the array step by step.
    Step 3: Create the Main Method
    Now we test the code.
    javaCopyEditpublic static void main{
    intnumbers = {9, 5, 1, 4, 3};

    System.out.println;
    printArray;

    insertionSort;

    System.out.println;
    printArray;
    }

    This method:

    Creates an array of numbers
    Prints the array before sorting
    Calls the sort method
    Prints the array after sorting

    Step 4: Print the Array
    Let’s add a helper method to print the array.
    javaCopyEditpublic static void printArray{
    for{
    System.out.print;
    }
    System.out.println;
    }

    Now you can see how the array changes before and after sorting.
    Full Code Example
    javaCopyEditpublic class InsertionSortExample {

    public static void insertionSort{
    int n = arr.length;
    for{
    int key = arr;
    int j = i - 1;

    while{
    arr= arr;
    j = j - 1;
    }
    arr= key;
    }
    }

    public static void printArray{
    for{
    System.out.print;
    }
    System.out.println;
    }

    public static void main{
    intnumbers = {9, 5, 1, 4, 3};

    System.out.println;
    printArray;

    insertionSort;

    System.out.println;
    printArray;
    }
    }

    Sample Output
    yamlCopyEditBefore sorting:
    9 5 1 4 3
    After sorting:
    1 3 4 5 9

    This confirms that the sorting works correctly.
    Advantages of Insertion Sort in Java

    Easy to implement
    Works well with small inputs
    Stable sortGood for educational use

    When Not to Use Insertion Sort
    Avoid Insertion Sort when:

    The dataset is large
    Performance is critical
    Better algorithms like Merge Sort or Quick Sort are available

    Real-World Uses

    Sorting small records in a database
    Teaching algorithm basics
    Handling partially sorted arrays

    Even though it is not the fastest, it is useful in many simple tasks.
    Final Tips

    Practice with different inputs
    Add print statements to see how it works
    Try sorting strings or objects
    Use Java’s built-in sort methods for large arrays

    Conclusion
    Insertion Sort in Java is a great way to learn sorting. It is simple and easy to understand. In this guide, we showed how to implement it step-by-step. We covered the logic, code, and output. We also explained when to use it. Now you can try it yourself. Understanding sorting helps in coding interviews and software development. Keep practicing and exploring other sorting methods too. The more you practice, the better you understand algorithms.
    Tech World TimesTech World Times, a global collective focusing on the latest tech news and trends in blockchain, Fintech, Development & Testing, AI and Startups. If you are looking for the guest post then contact at techworldtimes@gmail.com
    #how #implement #insertion #sort #java
    How to Implement Insertion Sort in Java: Step-by-Step Guide
    Posted on : June 13, 2025 By Tech World Times Uncategorized  Rate this post Sorting is important in programming. It helps organize data. Sorting improves performance in searching, analysis, and reporting. There are many sorting algorithms. One of the simplest is Insertion Sort. In this article, we will learn how to implement Insertion Sort in Java. We will explain each step in simple words. You will see examples and understand how it works. What Is Insertion Sort? Insertion Sort is a simple sorting algorithm. It works like how you sort playing cards. You take one card at a time and place it in the right position. It compares the current element with those before it. If needed, it shifts elements to the right. Then, it inserts the current element at the correct place. How Insertion Sort Works Let’s understand with a small list: Example List:Steps: First elementis already sorted. Compare 3 with 8. Move 8 right. Insert 3 before it →Compare 5 with 8. Move 8 right. Insert 5 after 3 →Compare 1 with 8, 5, 3. Move them right. Insert 1 at start →Now the list is sorted! Why Use Insertion Sort? Insertion Sort is simple and easy to code. It works well for: Small datasets Nearly sorted lists Educational purposes and practice However, it is not good for large datasets. It has a time complexity of O. Time Complexity of Insertion Sort Best Case: OAverage Case: OWorst Case: OIt performs fewer steps in nearly sorted data. How to Implement Insertion Sort in Java Now let’s write the code for Insertion Sort in Java. We will explain each part. Step 1: Define a Class javaCopyEditpublic class InsertionSortExample { // Code goes here } We create a class named InsertionSortExample. Step 2: Create the Sorting Method javaCopyEditpublic static void insertionSort{ int n = arr.length; for{ int key = arr; int j = i - 1; while{ arr= arr; j = j - 1; } arr= key; } } Let’s break it down: arris the current value. j starts from the previous index. While arr> key, shift arrto the right. Insert the key at the correct position. This logic sorts the array step by step. Step 3: Create the Main Method Now we test the code. javaCopyEditpublic static void main{ intnumbers = {9, 5, 1, 4, 3}; System.out.println; printArray; insertionSort; System.out.println; printArray; } This method: Creates an array of numbers Prints the array before sorting Calls the sort method Prints the array after sorting Step 4: Print the Array Let’s add a helper method to print the array. javaCopyEditpublic static void printArray{ for{ System.out.print; } System.out.println; } Now you can see how the array changes before and after sorting. Full Code Example javaCopyEditpublic class InsertionSortExample { public static void insertionSort{ int n = arr.length; for{ int key = arr; int j = i - 1; while{ arr= arr; j = j - 1; } arr= key; } } public static void printArray{ for{ System.out.print; } System.out.println; } public static void main{ intnumbers = {9, 5, 1, 4, 3}; System.out.println; printArray; insertionSort; System.out.println; printArray; } } Sample Output yamlCopyEditBefore sorting: 9 5 1 4 3 After sorting: 1 3 4 5 9 This confirms that the sorting works correctly. Advantages of Insertion Sort in Java Easy to implement Works well with small inputs Stable sortGood for educational use When Not to Use Insertion Sort Avoid Insertion Sort when: The dataset is large Performance is critical Better algorithms like Merge Sort or Quick Sort are available Real-World Uses Sorting small records in a database Teaching algorithm basics Handling partially sorted arrays Even though it is not the fastest, it is useful in many simple tasks. Final Tips Practice with different inputs Add print statements to see how it works Try sorting strings or objects Use Java’s built-in sort methods for large arrays Conclusion Insertion Sort in Java is a great way to learn sorting. It is simple and easy to understand. In this guide, we showed how to implement it step-by-step. We covered the logic, code, and output. We also explained when to use it. Now you can try it yourself. Understanding sorting helps in coding interviews and software development. Keep practicing and exploring other sorting methods too. The more you practice, the better you understand algorithms. Tech World TimesTech World Times, a global collective focusing on the latest tech news and trends in blockchain, Fintech, Development & Testing, AI and Startups. If you are looking for the guest post then contact at techworldtimes@gmail.com #how #implement #insertion #sort #java
    TECHWORLDTIMES.COM
    How to Implement Insertion Sort in Java: Step-by-Step Guide
    Posted on : June 13, 2025 By Tech World Times Uncategorized  Rate this post Sorting is important in programming. It helps organize data. Sorting improves performance in searching, analysis, and reporting. There are many sorting algorithms. One of the simplest is Insertion Sort. In this article, we will learn how to implement Insertion Sort in Java. We will explain each step in simple words. You will see examples and understand how it works. What Is Insertion Sort? Insertion Sort is a simple sorting algorithm. It works like how you sort playing cards. You take one card at a time and place it in the right position. It compares the current element with those before it. If needed, it shifts elements to the right. Then, it inserts the current element at the correct place. How Insertion Sort Works Let’s understand with a small list: Example List: [8, 3, 5, 1] Steps: First element (8) is already sorted. Compare 3 with 8. Move 8 right. Insert 3 before it → [3, 8, 5, 1] Compare 5 with 8. Move 8 right. Insert 5 after 3 → [3, 5, 8, 1] Compare 1 with 8, 5, 3. Move them right. Insert 1 at start → [1, 3, 5, 8] Now the list is sorted! Why Use Insertion Sort? Insertion Sort is simple and easy to code. It works well for: Small datasets Nearly sorted lists Educational purposes and practice However, it is not good for large datasets. It has a time complexity of O(n²). Time Complexity of Insertion Sort Best Case (already sorted): O(n) Average Case: O(n²) Worst Case (reversed list): O(n²) It performs fewer steps in nearly sorted data. How to Implement Insertion Sort in Java Now let’s write the code for Insertion Sort in Java. We will explain each part. Step 1: Define a Class javaCopyEditpublic class InsertionSortExample { // Code goes here } We create a class named InsertionSortExample. Step 2: Create the Sorting Method javaCopyEditpublic static void insertionSort(int[] arr) { int n = arr.length; for (int i = 1; i < n; i++) { int key = arr[i]; int j = i - 1; while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]; j = j - 1; } arr[j + 1] = key; } } Let’s break it down: arr[i] is the current value (called key). j starts from the previous index. While arr[j] > key, shift arr[j] to the right. Insert the key at the correct position. This logic sorts the array step by step. Step 3: Create the Main Method Now we test the code. javaCopyEditpublic static void main(String[] args) { int[] numbers = {9, 5, 1, 4, 3}; System.out.println("Before sorting:"); printArray(numbers); insertionSort(numbers); System.out.println("After sorting:"); printArray(numbers); } This method: Creates an array of numbers Prints the array before sorting Calls the sort method Prints the array after sorting Step 4: Print the Array Let’s add a helper method to print the array. javaCopyEditpublic static void printArray(int[] arr) { for (int number : arr) { System.out.print(number + " "); } System.out.println(); } Now you can see how the array changes before and after sorting. Full Code Example javaCopyEditpublic class InsertionSortExample { public static void insertionSort(int[] arr) { int n = arr.length; for (int i = 1; i < n; i++) { int key = arr[i]; int j = i - 1; while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]; j = j - 1; } arr[j + 1] = key; } } public static void printArray(int[] arr) { for (int number : arr) { System.out.print(number + " "); } System.out.println(); } public static void main(String[] args) { int[] numbers = {9, 5, 1, 4, 3}; System.out.println("Before sorting:"); printArray(numbers); insertionSort(numbers); System.out.println("After sorting:"); printArray(numbers); } } Sample Output yamlCopyEditBefore sorting: 9 5 1 4 3 After sorting: 1 3 4 5 9 This confirms that the sorting works correctly. Advantages of Insertion Sort in Java Easy to implement Works well with small inputs Stable sort (keeps equal items in order) Good for educational use When Not to Use Insertion Sort Avoid Insertion Sort when: The dataset is large Performance is critical Better algorithms like Merge Sort or Quick Sort are available Real-World Uses Sorting small records in a database Teaching algorithm basics Handling partially sorted arrays Even though it is not the fastest, it is useful in many simple tasks. Final Tips Practice with different inputs Add print statements to see how it works Try sorting strings or objects Use Java’s built-in sort methods for large arrays Conclusion Insertion Sort in Java is a great way to learn sorting. It is simple and easy to understand. In this guide, we showed how to implement it step-by-step. We covered the logic, code, and output. We also explained when to use it. Now you can try it yourself. Understanding sorting helps in coding interviews and software development. Keep practicing and exploring other sorting methods too. The more you practice, the better you understand algorithms. Tech World TimesTech World Times (TWT), a global collective focusing on the latest tech news and trends in blockchain, Fintech, Development & Testing, AI and Startups. If you are looking for the guest post then contact at techworldtimes@gmail.com
    0 Комментарии 0 Поделились
  • 9 menial tasks ChatGPT can handle in seconds, saving you hours

    ChatGPT is rapidly changing the world. The process is already happening, and it’s only going to accelerate as the technology improves, as more people gain access to it, and as more learn how to use it.
    What’s shocking is just how many tasks ChatGPT is already capable of managing for you. While the naysayers may still look down their noses at the potential of AI assistants, I’ve been using it to handle all kinds of menial tasks for me. Here are my favorite examples.

    Further reading: This tiny ChatGPT feature helps me tackle my days more productively

    Write your emails for you
    Dave Parrack / Foundry
    We’ve all been faced with the tricky task of writing an email—whether personal or professional—but not knowing quite how to word it. ChatGPT can do the heavy lifting for you, penning theperfect email based on whatever information you feed it.
    Let’s assume the email you need to write is of a professional nature, and wording it poorly could negatively affect your career. By directing ChatGPT to write the email with a particular structure, content, and tone of voice, you can give yourself a huge head start.
    A winning tip for this is to never accept ChatGPT’s first attempt. Always read through it and look for areas of improvement, then request tweaks to ensure you get the best possible email. You canalso rewrite the email in your own voice. Learn more about how ChatGPT coached my colleague to write better emails.

    Generate itineraries and schedules
    Dave Parrack / Foundry
    If you’re going on a trip but you’re the type of person who hates planning trips, then you should utilize ChatGPT’s ability to generate trip itineraries. The results can be customized to the nth degree depending on how much detail and instruction you’re willing to provide.
    As someone who likes to get away at least once a year but also wants to make the most of every trip, leaning on ChatGPT for an itinerary is essential for me. I’ll provide the location and the kinds of things I want to see and do, then let it handle the rest. Instead of spending days researching everything myself, ChatGPT does 80 percent of it for me.
    As with all of these tasks, you don’t need to accept ChatGPT’s first effort. Use different prompts to force the AI chatbot to shape the itinerary closer to what you want. You’d be surprised at how many cool ideas you’ll encounter this way—simply nix the ones you don’t like.

    Break down difficult concepts
    Dave Parrack / Foundry
    One of the best tasks to assign to ChatGPT is the explanation of difficult concepts. Ask ChatGPT to explain any concept you can think of and it will deliver more often than not. You can tailor the level of explanation you need, and even have it include visual elements.
    Let’s say, for example, that a higher-up at work regularly lectures everyone about the importance of networking. But maybe they never go into detail about what they mean, just constantly pushing the why without explaining the what. Well, just ask ChatGPT to explain networking!
    Okay, most of us know what “networking” is and the concept isn’t very hard to grasp. But you can do this with anything. Ask ChatGPT to explain augmented reality, multi-threaded processing, blockchain, large language models, what have you. It will provide you with a clear and simple breakdown, maybe even with analogies and images.

    Analyze and make tough decisions
    Dave Parrack / Foundry
    We all face tough decisions every so often. The next time you find yourself wrestling with a particularly tough one—and you just can’t decide one way or the other—try asking ChatGPT for guidance and advice.
    It may sound strange to trust any kind of decision to artificial intelligence, let alone an important one that has you stumped, but doing so actually makes a lot of sense. While human judgment can be clouded by emotions, AI can set that aside and prioritize logic.
    It should go without saying: you don’t have to accept ChatGPT’s answers. Use the AI to weigh the pros and cons, to help you understand what’s most important to you, and to suggest a direction. Who knows? If you find yourself not liking the answer given, that in itself might clarify what you actually want—and the right answer for you. This is the kind of stuff ChatGPT can do to improve your life.

    Plan complex projects and strategies
    Dave Parrack / Foundry
    Most jobs come with some level of project planning and management. Even I, as a freelance writer, need to plan tasks to get projects completed on time. And that’s where ChatGPT can prove invaluable, breaking projects up into smaller, more manageable parts.
    ChatGPT needs to know the nature of the project, the end goal, any constraints you may have, and what you have done so far. With that information, it can then break the project up with a step-by-step plan, and break it down further into phases.
    If ChatGPT doesn’t initially split your project up in a way that suits you, try again. Change up the prompts and make the AI chatbot tune in to exactly what you’re looking for. It takes a bit of back and forth, but it can shorten your planning time from hours to mere minutes.

    Compile research notes
    Dave Parrack / Foundry
    If you need to research a given topic of interest, ChatGPT can save you the hassle of compiling that research. For example, ahead of a trip to Croatia, I wanted to know more about the Croatian War of Independence, so I asked ChatGPT to provide me with a brief summary of the conflict with bullet points to help me understand how it happened.
    After absorbing all that information, I asked ChatGPT to add a timeline of the major events, further helping me to understand how the conflict played out. ChatGPT then offered to provide me with battle maps and/or summaries, plus profiles of the main players.
    You can go even deeper with ChatGPT’s Deep Research feature, which is now available to free users, up to 5 Deep Research tasks per month. With Deep Research, ChatGPT conducts multi-step research to generate comprehensive reportsbased on large amounts of information across the internet. A Deep Research task can take up to 30 minutes to complete, but it’ll save you hours or even days.

    Summarize articles, meetings, and more
    Dave Parrack / Foundry
    There are only so many hours in the day, yet so many new articles published on the web day in and day out. When you come across extra-long reads, it can be helpful to run them through ChatGPT for a quick summary. Then, if the summary is lacking in any way, you can go back and plow through the article proper.
    As an example, I ran one of my own PCWorld articlesthrough ChatGPT, which provided a brief summary of my points and broke down the best X alternative based on my reasons given. Interestingly, it also pulled elements from other articles.If you don’t want that, you can tell ChatGPT to limit its summary to the contents of the link.
    This is a great trick to use for other long-form, text-heavy content that you just don’t have the time to crunch through. Think transcripts for interviews, lectures, videos, and Zoom meetings. The only caveat is to never share private details with ChatGPT, like company-specific data that’s protected by NDAs and the like.

    Create Q&A flashcards for learning
    Dave Parrack / Foundry
    Flashcards can be extremely useful for drilling a lot of information into your brain, such as when studying for an exam, onboarding in a new role, prepping for an interview, etc. And with ChatGPT, you no longer have to painstakingly create those flashcards yourself. All you have to do is tell the AI the details of what you’re studying.
    You can specify the format, as well as various other elements. You can also choose to keep things broad or target specific sub-topics or concepts you want to focus on. You can even upload your own notes for ChatGPT to reference. You can also use Google’s NotebookLM app in a similar way.

    Provide interview practice
    Dave Parrack / Foundry
    Whether you’re a first-time jobseeker or have plenty of experience under your belt, it’s always a good idea to practice for your interviews when making career moves. Years ago, you might’ve had to ask a friend or family member to act as your mock interviewer. These days, ChatGPT can do it for you—and do it more effectively.
    Inform ChatGPT of the job title, industry, and level of position you’re interviewing for, what kind of interview it’ll be, and anything else you want it to take into consideration. ChatGPT will then conduct a mock interview with you, providing feedback along the way.
    When I tried this out myself, I was shocked by how capable ChatGPT can be at pretending to be a human in this context. And the feedback it provides for each answer you give is invaluable for knocking off your rough edges and improving your chances of success when you’re interviewed by a real hiring manager.
    Further reading: Non-gimmicky AI apps I actually use every day
    #menial #tasks #chatgpt #can #handle
    9 menial tasks ChatGPT can handle in seconds, saving you hours
    ChatGPT is rapidly changing the world. The process is already happening, and it’s only going to accelerate as the technology improves, as more people gain access to it, and as more learn how to use it. What’s shocking is just how many tasks ChatGPT is already capable of managing for you. While the naysayers may still look down their noses at the potential of AI assistants, I’ve been using it to handle all kinds of menial tasks for me. Here are my favorite examples. Further reading: This tiny ChatGPT feature helps me tackle my days more productively Write your emails for you Dave Parrack / Foundry We’ve all been faced with the tricky task of writing an email—whether personal or professional—but not knowing quite how to word it. ChatGPT can do the heavy lifting for you, penning theperfect email based on whatever information you feed it. Let’s assume the email you need to write is of a professional nature, and wording it poorly could negatively affect your career. By directing ChatGPT to write the email with a particular structure, content, and tone of voice, you can give yourself a huge head start. A winning tip for this is to never accept ChatGPT’s first attempt. Always read through it and look for areas of improvement, then request tweaks to ensure you get the best possible email. You canalso rewrite the email in your own voice. Learn more about how ChatGPT coached my colleague to write better emails. Generate itineraries and schedules Dave Parrack / Foundry If you’re going on a trip but you’re the type of person who hates planning trips, then you should utilize ChatGPT’s ability to generate trip itineraries. The results can be customized to the nth degree depending on how much detail and instruction you’re willing to provide. As someone who likes to get away at least once a year but also wants to make the most of every trip, leaning on ChatGPT for an itinerary is essential for me. I’ll provide the location and the kinds of things I want to see and do, then let it handle the rest. Instead of spending days researching everything myself, ChatGPT does 80 percent of it for me. As with all of these tasks, you don’t need to accept ChatGPT’s first effort. Use different prompts to force the AI chatbot to shape the itinerary closer to what you want. You’d be surprised at how many cool ideas you’ll encounter this way—simply nix the ones you don’t like. Break down difficult concepts Dave Parrack / Foundry One of the best tasks to assign to ChatGPT is the explanation of difficult concepts. Ask ChatGPT to explain any concept you can think of and it will deliver more often than not. You can tailor the level of explanation you need, and even have it include visual elements. Let’s say, for example, that a higher-up at work regularly lectures everyone about the importance of networking. But maybe they never go into detail about what they mean, just constantly pushing the why without explaining the what. Well, just ask ChatGPT to explain networking! Okay, most of us know what “networking” is and the concept isn’t very hard to grasp. But you can do this with anything. Ask ChatGPT to explain augmented reality, multi-threaded processing, blockchain, large language models, what have you. It will provide you with a clear and simple breakdown, maybe even with analogies and images. Analyze and make tough decisions Dave Parrack / Foundry We all face tough decisions every so often. The next time you find yourself wrestling with a particularly tough one—and you just can’t decide one way or the other—try asking ChatGPT for guidance and advice. It may sound strange to trust any kind of decision to artificial intelligence, let alone an important one that has you stumped, but doing so actually makes a lot of sense. While human judgment can be clouded by emotions, AI can set that aside and prioritize logic. It should go without saying: you don’t have to accept ChatGPT’s answers. Use the AI to weigh the pros and cons, to help you understand what’s most important to you, and to suggest a direction. Who knows? If you find yourself not liking the answer given, that in itself might clarify what you actually want—and the right answer for you. This is the kind of stuff ChatGPT can do to improve your life. Plan complex projects and strategies Dave Parrack / Foundry Most jobs come with some level of project planning and management. Even I, as a freelance writer, need to plan tasks to get projects completed on time. And that’s where ChatGPT can prove invaluable, breaking projects up into smaller, more manageable parts. ChatGPT needs to know the nature of the project, the end goal, any constraints you may have, and what you have done so far. With that information, it can then break the project up with a step-by-step plan, and break it down further into phases. If ChatGPT doesn’t initially split your project up in a way that suits you, try again. Change up the prompts and make the AI chatbot tune in to exactly what you’re looking for. It takes a bit of back and forth, but it can shorten your planning time from hours to mere minutes. Compile research notes Dave Parrack / Foundry If you need to research a given topic of interest, ChatGPT can save you the hassle of compiling that research. For example, ahead of a trip to Croatia, I wanted to know more about the Croatian War of Independence, so I asked ChatGPT to provide me with a brief summary of the conflict with bullet points to help me understand how it happened. After absorbing all that information, I asked ChatGPT to add a timeline of the major events, further helping me to understand how the conflict played out. ChatGPT then offered to provide me with battle maps and/or summaries, plus profiles of the main players. You can go even deeper with ChatGPT’s Deep Research feature, which is now available to free users, up to 5 Deep Research tasks per month. With Deep Research, ChatGPT conducts multi-step research to generate comprehensive reportsbased on large amounts of information across the internet. A Deep Research task can take up to 30 minutes to complete, but it’ll save you hours or even days. Summarize articles, meetings, and more Dave Parrack / Foundry There are only so many hours in the day, yet so many new articles published on the web day in and day out. When you come across extra-long reads, it can be helpful to run them through ChatGPT for a quick summary. Then, if the summary is lacking in any way, you can go back and plow through the article proper. As an example, I ran one of my own PCWorld articlesthrough ChatGPT, which provided a brief summary of my points and broke down the best X alternative based on my reasons given. Interestingly, it also pulled elements from other articles.If you don’t want that, you can tell ChatGPT to limit its summary to the contents of the link. This is a great trick to use for other long-form, text-heavy content that you just don’t have the time to crunch through. Think transcripts for interviews, lectures, videos, and Zoom meetings. The only caveat is to never share private details with ChatGPT, like company-specific data that’s protected by NDAs and the like. Create Q&A flashcards for learning Dave Parrack / Foundry Flashcards can be extremely useful for drilling a lot of information into your brain, such as when studying for an exam, onboarding in a new role, prepping for an interview, etc. And with ChatGPT, you no longer have to painstakingly create those flashcards yourself. All you have to do is tell the AI the details of what you’re studying. You can specify the format, as well as various other elements. You can also choose to keep things broad or target specific sub-topics or concepts you want to focus on. You can even upload your own notes for ChatGPT to reference. You can also use Google’s NotebookLM app in a similar way. Provide interview practice Dave Parrack / Foundry Whether you’re a first-time jobseeker or have plenty of experience under your belt, it’s always a good idea to practice for your interviews when making career moves. Years ago, you might’ve had to ask a friend or family member to act as your mock interviewer. These days, ChatGPT can do it for you—and do it more effectively. Inform ChatGPT of the job title, industry, and level of position you’re interviewing for, what kind of interview it’ll be, and anything else you want it to take into consideration. ChatGPT will then conduct a mock interview with you, providing feedback along the way. When I tried this out myself, I was shocked by how capable ChatGPT can be at pretending to be a human in this context. And the feedback it provides for each answer you give is invaluable for knocking off your rough edges and improving your chances of success when you’re interviewed by a real hiring manager. Further reading: Non-gimmicky AI apps I actually use every day #menial #tasks #chatgpt #can #handle
    WWW.PCWORLD.COM
    9 menial tasks ChatGPT can handle in seconds, saving you hours
    ChatGPT is rapidly changing the world. The process is already happening, and it’s only going to accelerate as the technology improves, as more people gain access to it, and as more learn how to use it. What’s shocking is just how many tasks ChatGPT is already capable of managing for you. While the naysayers may still look down their noses at the potential of AI assistants, I’ve been using it to handle all kinds of menial tasks for me. Here are my favorite examples. Further reading: This tiny ChatGPT feature helps me tackle my days more productively Write your emails for you Dave Parrack / Foundry We’ve all been faced with the tricky task of writing an email—whether personal or professional—but not knowing quite how to word it. ChatGPT can do the heavy lifting for you, penning the (hopefully) perfect email based on whatever information you feed it. Let’s assume the email you need to write is of a professional nature, and wording it poorly could negatively affect your career. By directing ChatGPT to write the email with a particular structure, content, and tone of voice, you can give yourself a huge head start. A winning tip for this is to never accept ChatGPT’s first attempt. Always read through it and look for areas of improvement, then request tweaks to ensure you get the best possible email. You can (and should) also rewrite the email in your own voice. Learn more about how ChatGPT coached my colleague to write better emails. Generate itineraries and schedules Dave Parrack / Foundry If you’re going on a trip but you’re the type of person who hates planning trips, then you should utilize ChatGPT’s ability to generate trip itineraries. The results can be customized to the nth degree depending on how much detail and instruction you’re willing to provide. As someone who likes to get away at least once a year but also wants to make the most of every trip, leaning on ChatGPT for an itinerary is essential for me. I’ll provide the location and the kinds of things I want to see and do, then let it handle the rest. Instead of spending days researching everything myself, ChatGPT does 80 percent of it for me. As with all of these tasks, you don’t need to accept ChatGPT’s first effort. Use different prompts to force the AI chatbot to shape the itinerary closer to what you want. You’d be surprised at how many cool ideas you’ll encounter this way—simply nix the ones you don’t like. Break down difficult concepts Dave Parrack / Foundry One of the best tasks to assign to ChatGPT is the explanation of difficult concepts. Ask ChatGPT to explain any concept you can think of and it will deliver more often than not. You can tailor the level of explanation you need, and even have it include visual elements. Let’s say, for example, that a higher-up at work regularly lectures everyone about the importance of networking. But maybe they never go into detail about what they mean, just constantly pushing the why without explaining the what. Well, just ask ChatGPT to explain networking! Okay, most of us know what “networking” is and the concept isn’t very hard to grasp. But you can do this with anything. Ask ChatGPT to explain augmented reality, multi-threaded processing, blockchain, large language models, what have you. It will provide you with a clear and simple breakdown, maybe even with analogies and images. Analyze and make tough decisions Dave Parrack / Foundry We all face tough decisions every so often. The next time you find yourself wrestling with a particularly tough one—and you just can’t decide one way or the other—try asking ChatGPT for guidance and advice. It may sound strange to trust any kind of decision to artificial intelligence, let alone an important one that has you stumped, but doing so actually makes a lot of sense. While human judgment can be clouded by emotions, AI can set that aside and prioritize logic. It should go without saying: you don’t have to accept ChatGPT’s answers. Use the AI to weigh the pros and cons, to help you understand what’s most important to you, and to suggest a direction. Who knows? If you find yourself not liking the answer given, that in itself might clarify what you actually want—and the right answer for you. This is the kind of stuff ChatGPT can do to improve your life. Plan complex projects and strategies Dave Parrack / Foundry Most jobs come with some level of project planning and management. Even I, as a freelance writer, need to plan tasks to get projects completed on time. And that’s where ChatGPT can prove invaluable, breaking projects up into smaller, more manageable parts. ChatGPT needs to know the nature of the project, the end goal, any constraints you may have, and what you have done so far. With that information, it can then break the project up with a step-by-step plan, and break it down further into phases (if required). If ChatGPT doesn’t initially split your project up in a way that suits you, try again. Change up the prompts and make the AI chatbot tune in to exactly what you’re looking for. It takes a bit of back and forth, but it can shorten your planning time from hours to mere minutes. Compile research notes Dave Parrack / Foundry If you need to research a given topic of interest, ChatGPT can save you the hassle of compiling that research. For example, ahead of a trip to Croatia, I wanted to know more about the Croatian War of Independence, so I asked ChatGPT to provide me with a brief summary of the conflict with bullet points to help me understand how it happened. After absorbing all that information, I asked ChatGPT to add a timeline of the major events, further helping me to understand how the conflict played out. ChatGPT then offered to provide me with battle maps and/or summaries, plus profiles of the main players. You can go even deeper with ChatGPT’s Deep Research feature, which is now available to free users, up to 5 Deep Research tasks per month. With Deep Research, ChatGPT conducts multi-step research to generate comprehensive reports (with citations!) based on large amounts of information across the internet. A Deep Research task can take up to 30 minutes to complete, but it’ll save you hours or even days. Summarize articles, meetings, and more Dave Parrack / Foundry There are only so many hours in the day, yet so many new articles published on the web day in and day out. When you come across extra-long reads, it can be helpful to run them through ChatGPT for a quick summary. Then, if the summary is lacking in any way, you can go back and plow through the article proper. As an example, I ran one of my own PCWorld articles (where I compared Bluesky and Threads as alternatives to X) through ChatGPT, which provided a brief summary of my points and broke down the best X alternative based on my reasons given. Interestingly, it also pulled elements from other articles. (Hmph.) If you don’t want that, you can tell ChatGPT to limit its summary to the contents of the link. This is a great trick to use for other long-form, text-heavy content that you just don’t have the time to crunch through. Think transcripts for interviews, lectures, videos, and Zoom meetings. The only caveat is to never share private details with ChatGPT, like company-specific data that’s protected by NDAs and the like. Create Q&A flashcards for learning Dave Parrack / Foundry Flashcards can be extremely useful for drilling a lot of information into your brain, such as when studying for an exam, onboarding in a new role, prepping for an interview, etc. And with ChatGPT, you no longer have to painstakingly create those flashcards yourself. All you have to do is tell the AI the details of what you’re studying. You can specify the format (such as Q&A or multiple choice), as well as various other elements. You can also choose to keep things broad or target specific sub-topics or concepts you want to focus on. You can even upload your own notes for ChatGPT to reference. You can also use Google’s NotebookLM app in a similar way. Provide interview practice Dave Parrack / Foundry Whether you’re a first-time jobseeker or have plenty of experience under your belt, it’s always a good idea to practice for your interviews when making career moves. Years ago, you might’ve had to ask a friend or family member to act as your mock interviewer. These days, ChatGPT can do it for you—and do it more effectively. Inform ChatGPT of the job title, industry, and level of position you’re interviewing for, what kind of interview it’ll be (e.g., screener, technical assessment, group/panel, one-on-one with CEO), and anything else you want it to take into consideration. ChatGPT will then conduct a mock interview with you, providing feedback along the way. When I tried this out myself, I was shocked by how capable ChatGPT can be at pretending to be a human in this context. And the feedback it provides for each answer you give is invaluable for knocking off your rough edges and improving your chances of success when you’re interviewed by a real hiring manager. Further reading: Non-gimmicky AI apps I actually use every day
    0 Комментарии 0 Поделились
  • Selection Sort Time Complexity: Best, Worst, and Average Cases

    Development and Testing 

    Rate this post

    Sorting is a basic task in programming. It arranges data in order. There are many sorting algorithms. Selection Sort is one of the simplest sorting methods. It is easy to understand and code. But it is not the fastest. In this guide, we will explain the Selection Sort Time Complexity. We will cover best, worst, and average cases.
    What Is Selection Sort?
    Selection Sort works by selecting the smallest element from the list. It places it in the correct position. It repeats this process for all elements. One by one, it moves the smallest values to the front.
    Let’s see an example:
    Input:Step 1: Smallest is 2 → swap with 5 →Step 2: Smallest in remaining is 3 → already correctStep 3: Smallest in remaining is 5 → swap with 8 →Now the list is sorted.How Selection Sort Works
    Selection Sort uses two loops. The outer loop moves one index at a time. The inner loop finds the smallest element. After each pass, the smallest value is moved to the front. The position is fixed. Selection Sort does not care if the list is sorted or not. It always does the same steps.
    Selection Sort Algorithm
    Here is the basic algorithm:

    Start from the first element
    Find the smallest in the rest of the list
    Swap it with the current element
    Repeat for each element

    This repeats until all elements are sorted.
    Selection Sort CodejavaCopyEditpublic class SelectionSort {
    public static void sort{
    int n = arr.length;
    for{
    int min = i;
    for{
    if{
    min = j;
    }
    }
    int temp = arr;
    arr= arr;
    arr= temp;
    }
    }
    }

    This code uses two loops. The outer loop runs n-1 times. The inner loop finds the minimum.
    Selection Sort Time Complexity
    Now let’s understand the main topic. Let’s analyze Selection Sort Time Complexity in three cases.
    1. Best Case
    Even if the array is already sorted, Selection Sort checks all elements. It keeps comparing and swapping.

    Time Complexity: OReason: Inner loop runs fully, regardless of the order
    Example Input:Even here, every comparison still happens. Only fewer swaps occur, but comparisons remain the same.
    2. Worst Case
    This happens when the array is in reverse order. But Selection Sort does not optimize for this.

    Time Complexity: OReason: Still needs full comparisons
    Example Input:Even in reverse, the steps are the same. It compares and finds the smallest element every time.
    3. Average Case
    This is when elements are randomly placed. It is the most common scenario in real-world problems.

    Time Complexity: OReason: Still compares each element in the inner loop
    Example Input:Selection Sort does not change behavior based on input order. So the complexity remains the same.
    Why Is It Always O?
    Selection Sort compares all pairs of elements. The number of comparisons does not change.
    Total comparisons = n ×/ 2
    That’s why the time complexity is always O.It does not reduce steps in any case. It does not take advantage of sorted elements.
    Space Complexity
    Selection Sort does not need extra space. It sorts in place.

    Space Complexity: OOnly a few variables are used
    No extra arrays or memory needed

    This is one good point of the Selection Sort.
    Comparison with Other Algorithms
    Let’s compare Selection Sort with other basic sorts:
    AlgorithmBest CaseAverage CaseWorst CaseSpaceSelection SortOOOOBubble SortOOOOInsertion SortOOOOMerge SortOOOOQuick SortOOOOAs you see, Selection Sort is slower than Merge Sort and Quick Sort.
    Advantages of Selection Sort

    Very simple and easy to understand
    Works well with small datasets
    Needs very little memory
    Good for learning purposes

    Disadvantages of Selection Sort

    Slow on large datasets
    Always takes the same time, even if sorted
    Not efficient for real-world use

    When to Use Selection Sort
    Use Selection Sort when:

    You are working with a very small dataset
    You want to teach or learn sorting logic
    You want stable, low-memory sorting

    Avoid it for:

    Large datasets
    Performance-sensitive programs

    Conclusion
    Selection Sort Time Complexity is simple to understand. But it is not efficient for big problems. It always takes Otime, no matter the case. That is the same for best, worst, and average inputs. Still, it is useful in some cases. It’s great for learning sorting basics. It uses very little memory. If you’re working with small arrays, Selection Sort is fine. For large data, use better algorithms. Understanding its time complexity helps you choose the right algorithm. Always pick the tool that fits your task.
    Tech World TimesTech World Times, a global collective focusing on the latest tech news and trends in blockchain, Fintech, Development & Testing, AI and Startups. If you are looking for the guest post then contact at techworldtimes@gmail.com
    #selection #sort #time #complexity #best
    Selection Sort Time Complexity: Best, Worst, and Average Cases
    Development and Testing  Rate this post Sorting is a basic task in programming. It arranges data in order. There are many sorting algorithms. Selection Sort is one of the simplest sorting methods. It is easy to understand and code. But it is not the fastest. In this guide, we will explain the Selection Sort Time Complexity. We will cover best, worst, and average cases. What Is Selection Sort? Selection Sort works by selecting the smallest element from the list. It places it in the correct position. It repeats this process for all elements. One by one, it moves the smallest values to the front. Let’s see an example: Input:Step 1: Smallest is 2 → swap with 5 →Step 2: Smallest in remaining is 3 → already correctStep 3: Smallest in remaining is 5 → swap with 8 →Now the list is sorted.How Selection Sort Works Selection Sort uses two loops. The outer loop moves one index at a time. The inner loop finds the smallest element. After each pass, the smallest value is moved to the front. The position is fixed. Selection Sort does not care if the list is sorted or not. It always does the same steps. Selection Sort Algorithm Here is the basic algorithm: Start from the first element Find the smallest in the rest of the list Swap it with the current element Repeat for each element This repeats until all elements are sorted. Selection Sort CodejavaCopyEditpublic class SelectionSort { public static void sort{ int n = arr.length; for{ int min = i; for{ if{ min = j; } } int temp = arr; arr= arr; arr= temp; } } } This code uses two loops. The outer loop runs n-1 times. The inner loop finds the minimum. Selection Sort Time Complexity Now let’s understand the main topic. Let’s analyze Selection Sort Time Complexity in three cases. 1. Best Case Even if the array is already sorted, Selection Sort checks all elements. It keeps comparing and swapping. Time Complexity: OReason: Inner loop runs fully, regardless of the order Example Input:Even here, every comparison still happens. Only fewer swaps occur, but comparisons remain the same. 2. Worst Case This happens when the array is in reverse order. But Selection Sort does not optimize for this. Time Complexity: OReason: Still needs full comparisons Example Input:Even in reverse, the steps are the same. It compares and finds the smallest element every time. 3. Average Case This is when elements are randomly placed. It is the most common scenario in real-world problems. Time Complexity: OReason: Still compares each element in the inner loop Example Input:Selection Sort does not change behavior based on input order. So the complexity remains the same. Why Is It Always O? Selection Sort compares all pairs of elements. The number of comparisons does not change. Total comparisons = n ×/ 2 That’s why the time complexity is always O.It does not reduce steps in any case. It does not take advantage of sorted elements. Space Complexity Selection Sort does not need extra space. It sorts in place. Space Complexity: OOnly a few variables are used No extra arrays or memory needed This is one good point of the Selection Sort. Comparison with Other Algorithms Let’s compare Selection Sort with other basic sorts: AlgorithmBest CaseAverage CaseWorst CaseSpaceSelection SortOOOOBubble SortOOOOInsertion SortOOOOMerge SortOOOOQuick SortOOOOAs you see, Selection Sort is slower than Merge Sort and Quick Sort. Advantages of Selection Sort Very simple and easy to understand Works well with small datasets Needs very little memory Good for learning purposes Disadvantages of Selection Sort Slow on large datasets Always takes the same time, even if sorted Not efficient for real-world use When to Use Selection Sort Use Selection Sort when: You are working with a very small dataset You want to teach or learn sorting logic You want stable, low-memory sorting Avoid it for: Large datasets Performance-sensitive programs Conclusion Selection Sort Time Complexity is simple to understand. But it is not efficient for big problems. It always takes Otime, no matter the case. That is the same for best, worst, and average inputs. Still, it is useful in some cases. It’s great for learning sorting basics. It uses very little memory. If you’re working with small arrays, Selection Sort is fine. For large data, use better algorithms. Understanding its time complexity helps you choose the right algorithm. Always pick the tool that fits your task. Tech World TimesTech World Times, a global collective focusing on the latest tech news and trends in blockchain, Fintech, Development & Testing, AI and Startups. If you are looking for the guest post then contact at techworldtimes@gmail.com #selection #sort #time #complexity #best
    TECHWORLDTIMES.COM
    Selection Sort Time Complexity: Best, Worst, and Average Cases
    Development and Testing  Rate this post Sorting is a basic task in programming. It arranges data in order. There are many sorting algorithms. Selection Sort is one of the simplest sorting methods. It is easy to understand and code. But it is not the fastest. In this guide, we will explain the Selection Sort Time Complexity. We will cover best, worst, and average cases. What Is Selection Sort? Selection Sort works by selecting the smallest element from the list. It places it in the correct position. It repeats this process for all elements. One by one, it moves the smallest values to the front. Let’s see an example: Input: [5, 3, 8, 2]Step 1: Smallest is 2 → swap with 5 → [2, 3, 8, 5]Step 2: Smallest in remaining is 3 → already correctStep 3: Smallest in remaining is 5 → swap with 8 → [2, 3, 5, 8] Now the list is sorted.How Selection Sort Works Selection Sort uses two loops. The outer loop moves one index at a time. The inner loop finds the smallest element. After each pass, the smallest value is moved to the front. The position is fixed. Selection Sort does not care if the list is sorted or not. It always does the same steps. Selection Sort Algorithm Here is the basic algorithm: Start from the first element Find the smallest in the rest of the list Swap it with the current element Repeat for each element This repeats until all elements are sorted. Selection Sort Code (Java Example) javaCopyEditpublic class SelectionSort { public static void sort(int[] arr) { int n = arr.length; for (int i = 0; i < n - 1; i++) { int min = i; for (int j = i + 1; j < n; j++) { if (arr[j] < arr[min]) { min = j; } } int temp = arr[min]; arr[min] = arr[i]; arr[i] = temp; } } } This code uses two loops. The outer loop runs n-1 times. The inner loop finds the minimum. Selection Sort Time Complexity Now let’s understand the main topic. Let’s analyze Selection Sort Time Complexity in three cases. 1. Best Case Even if the array is already sorted, Selection Sort checks all elements. It keeps comparing and swapping. Time Complexity: O(n²) Reason: Inner loop runs fully, regardless of the order Example Input: [1, 2, 3, 4, 5] Even here, every comparison still happens. Only fewer swaps occur, but comparisons remain the same. 2. Worst Case This happens when the array is in reverse order. But Selection Sort does not optimize for this. Time Complexity: O(n²) Reason: Still needs full comparisons Example Input: [5, 4, 3, 2, 1] Even in reverse, the steps are the same. It compares and finds the smallest element every time. 3. Average Case This is when elements are randomly placed. It is the most common scenario in real-world problems. Time Complexity: O(n²) Reason: Still compares each element in the inner loop Example Input: [3, 1, 4, 2, 5] Selection Sort does not change behavior based on input order. So the complexity remains the same. Why Is It Always O(n²)? Selection Sort compares all pairs of elements. The number of comparisons does not change. Total comparisons = n × (n – 1) / 2 That’s why the time complexity is always O(n²).It does not reduce steps in any case. It does not take advantage of sorted elements. Space Complexity Selection Sort does not need extra space. It sorts in place. Space Complexity: O(1) Only a few variables are used No extra arrays or memory needed This is one good point of the Selection Sort. Comparison with Other Algorithms Let’s compare Selection Sort with other basic sorts: AlgorithmBest CaseAverage CaseWorst CaseSpaceSelection SortO(n²)O(n²)O(n²)O(1)Bubble SortO(n)O(n²)O(n²)O(1)Insertion SortO(n)O(n²)O(n²)O(1)Merge SortO(n log n)O(n log n)O(n log n)O(n)Quick SortO(n log n)O(n log n)O(n²)O(log n) As you see, Selection Sort is slower than Merge Sort and Quick Sort. Advantages of Selection Sort Very simple and easy to understand Works well with small datasets Needs very little memory Good for learning purposes Disadvantages of Selection Sort Slow on large datasets Always takes the same time, even if sorted Not efficient for real-world use When to Use Selection Sort Use Selection Sort when: You are working with a very small dataset You want to teach or learn sorting logic You want stable, low-memory sorting Avoid it for: Large datasets Performance-sensitive programs Conclusion Selection Sort Time Complexity is simple to understand. But it is not efficient for big problems. It always takes O(n²) time, no matter the case. That is the same for best, worst, and average inputs. Still, it is useful in some cases. It’s great for learning sorting basics. It uses very little memory. If you’re working with small arrays, Selection Sort is fine. For large data, use better algorithms. Understanding its time complexity helps you choose the right algorithm. Always pick the tool that fits your task. Tech World TimesTech World Times (TWT), a global collective focusing on the latest tech news and trends in blockchain, Fintech, Development & Testing, AI and Startups. If you are looking for the guest post then contact at techworldtimes@gmail.com
    0 Комментарии 0 Поделились