Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
History is littered with hundreds of conflicts over the future of a community, group, location or business that were "resolved" when one of the parties stepped ahead and destroyed what was there. With the original point of contention destroyed, the debates would fall to the wayside. Archive Team believes that by duplicated condemned data, the conversation and debate can continue, as well as the richness and insight gained by keeping the materials. Our projects have ranged in size from a single volunteer downloading the data to a small-but-critical site, to over 100 volunteers stepping forward to acquire terabytes of user-created data to save for future generations.
The main site for Archive Team is at archiveteam.org and contains up to the date information on various projects, manifestos, plans and walkthroughs.
This collection contains the output of many Archive Team projects, both ongoing and completed. Thanks to the generous providing of disk space by the Internet Archive, multi-terabyte datasets can be made available, as well as in use by the Wayback Machine, providing a path back to lost websites and work.
Our collection has grown to the point of having sub-collections for the type of data we acquire. If you are seeking to browse the contents of these collections, the Wayback Machine is the best first stop. Otherwise, you are free to dig into the stacks to see what you may find.
The Archive Team Panic Downloads are full pulldowns of currently extant websites, meant to serve as emergency backups for needed sites that are in danger of closing, or which will be missed dearly if suddenly lost due to hard drive crashes or server failures.
Problem: Given an array arr[] of n elements, write a function to search a given element x in arr[].
Examples :
Input : arr[] = {10, 20, 80, 30, 60, 50,
110, 100, 130, 170}
x = 110;
Output : 6
Element x is present at index 6
Input : arr[] = {10, 20, 80, 30, 60, 50,
110, 100, 130, 170}
x = 175;
Output : -1
Element x is not present in arr[].
Start from the leftmost element of arr[] and one by one compare x with each element of arr[]
If x matches with an element, return the index.
If x doesn’t match with any of elements, return -1.
Example:
C++
// C++ code to linearly search x in arr[]. If x
// is present then return its location, otherwise
// return -1
#include <iostream>
usingnamespacestd;
intsearch(intarr[], intn, intx)
{
inti;
for(i = 0; i < n; i++)
if(arr[i] == x)
returni;
return-1;
}
// Driver code
intmain(void)
{
intarr[] = { 2, 3, 4, 10, 40 };
intx = 10;
intn = sizeof(arr) / sizeof(arr[0]);
// Function call
intresult = search(arr, n, x);
(result == -1)
? cout << "Element is not present in array"
: cout << "Element is present at index "<< result;
return0;
}
C
// C code to linearly search x in arr[]. If x
// is present then return its location, otherwise
// return -1
#include <stdio.h>
intsearch(intarr[], intn, intx)
{
inti;
for(i = 0; i < n; i++)
if(arr[i] == x)
returni;
return-1;
}
// Driver code
intmain(void)
{
intarr[] = { 2, 3, 4, 10, 40 };
intx = 10;
intn = sizeof(arr) / sizeof(arr[0]);
// Function call
intresult = search(arr, n, x);
(result == -1)
? printf("Element is not present in array")
: printf("Element is present at index %d", result);
return0;
}
Java
// Java code for linearly searching x in arr[]. If x
// is present then return its location, otherwise
// return -1
classGFG
{
publicstaticintsearch(intarr[], intx)
{
intn = arr.length;
for(inti = 0; i < n; i++)
{
if(arr[i] == x)
returni;
}
return-1;
}
// Driver code
publicstaticvoidmain(String args[])
{
intarr[] = { 2, 3, 4, 10, 40};
intx = 10;
// Function call
intresult = search(arr, x);
if(result == -1)
System.out.print(
"Element is not present in array");
else
System.out.print("Element is present at index "
+ result);
}
}
Python3
# Python3 code to linearly search x in arr[].
# If x is present then return its location,
# otherwise return -1
defsearch(arr, n, x):
fori inrange(0, n):
if(arr[i] ==x):
returni
return-1
# Driver Code
arr =[2, 3, 4, 10, 40]
x =10
n =len(arr)
# Function call
result =search(arr, n, x)
if(result ==-1):
print("Element is not present in array")
else:
print("Element is present at index", result)
C#
// C# code to linearly search x in arr[]. If x
// is present then return its location, otherwise
// return -1
usingSystem;
classGFG {
publicstaticintsearch(int[] arr, intx)
{
intn = arr.Length;
for(inti = 0; i < n; i++)
{
if(arr[i] == x)
returni;
}
return-1;
}
// Driver code
publicstaticvoidMain()
{
int[] arr = { 2, 3, 4, 10, 40 };
intx = 10;
// Function call
intresult = search(arr, x);
if(result == -1)
Console.WriteLine(
"Element is not present in array");
else
Console.WriteLine("Element is present at index "
+ result);
}
}
// This code is contributed by DrRoot_
PHP
<?php
// PHP code for linearly search x in arr[].
// If x is present then return its location,
// otherwise return -1
functionsearch($arr, $x)
{
$n= sizeof($arr);
for($i= 0; $i< $n; $i++)
{
if($arr[$i] == $x)
return$i;
}
return-1;
}
// Driver Code
$arr= array(2, 3, 4, 10, 40);
$x= 10;
// Function call
$result= search($arr, $x);
if($result== -1)
echo"Element is not present in array";
else
echo"Element is present at index ",
$result;
// This code is contributed
// by jit_t
?>
Javascript
<script>
// Javascript code to linearly search x in arr[]. If x
// is present then return its location, otherwise
// return -1
functionsearch(arr, n, x)
{
let i;
for(i = 0; i < n; i++)
if(arr[i] == x)
returni;
return-1;
}
// Driver code
let arr = [ 2, 3, 4, 10, 40 ];
let x = 10;
let n = arr.length;
// Function call
let result = search(arr, n, x);
(result == -1)
? document.write("Element is not present in array")
: document.write("Element is present at index "+ result);
// This code is contributed by Manoj
</script>
Output
Element is present at index 3
The time complexity of the above algorithm is O(n).
Linear search is rarely used practically because other search algorithms such as the binary search algorithm and hash tables allow significantly faster-searching comparison to Linear search.
Improve Linear Search Worst-Case Complexity
if element Found at last O(n) to O(1)
It is the same as previous method because here we are performing 2 ‘if’ operations in one iteration of the loop and in previous method we performed only 1 ‘if’ operation. This makes both the time complexities same.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy